<html>
<head><meta charset="utf-8"><title>The movemasquerade · project-portable-simd · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/index.html">project-portable-simd</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html">The movemasquerade</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="212502576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212502576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212502576">(Oct 07 2020 at 00:24)</a>:</h4>
<p><span class="user-mention silent" data-user-id="209168">Thom Chiovoloni</span> <a href="#narrow/stream/257879-project-portable-simd/topic/What.20core.3A.3Aarch.20users.20need.20from.20std.3A.3Asimd/near/212501034">said</a>:</p>
<blockquote>
<p>My point was more: a lot of code will end up using one or two weirder instructions that LLVM doesnt offer a portable equivalent. Say: <code>_mm_movemask_ps</code>¹ (this is not weird as in rarely used at all, it's just semantically a bit odd).</p>
<p>It's often pretty easy (trivial for movemask) to implement a portable equivalent to this, so we should support it even though it's not like LLVM will automatically implement the portable versions for us.</p>
</blockquote>
<p>not to detract from your point, but LLVM has portable intrinsics for masked load/store (IIRC same thing as <code>movemask</code>):<br>
<a href="https://llvm.org/docs/LangRef.html#masked-vector-load-and-store-intrinsics">https://llvm.org/docs/LangRef.html#masked-vector-load-and-store-intrinsics</a></p>



<a name="212502664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212502664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212502664">(Oct 07 2020 at 00:25)</a>:</h4>
<p>movemask isn't masked load/store (as i mentioned, intel is bad at names), it's "get me a integer where bit N is set if lane N of the mask is on" (well, it only actually looks at the LSB of the mask lane , but yah)</p>



<a name="212503992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212503992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212503992">(Oct 07 2020 at 00:51)</a>:</h4>
<p>(I think it's sign bit, not LSB)</p>



<a name="212504007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212504007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212504007">(Oct 07 2020 at 00:51)</a>:</h4>
<p>oh, possibly, it only looks at one of the bits either way.</p>



<a name="212510099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212510099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212510099">(Oct 07 2020 at 02:50)</a>:</h4>
<p><span class="user-mention silent" data-user-id="209168">Thom Chiovoloni</span> <a href="#narrow/stream/257879-project-portable-simd/topic/What.20core.3A.3Aarch.20users.20need.20from.20std.3A.3Asimd/near/212502664">said</a>:</p>
<blockquote>
<p>movemask isn't masked load/store (as i mentioned, intel is bad at names), it's "get me a integer where bit N is set if lane N of the mask is on" (well, it only actually looks at the LSB of the mask lane , but yah)</p>
</blockquote>
<p>Oh, you mean (with MSB instead of LSB as <span class="user-mention" data-user-id="224471">@Lokathor</span> mentioned):</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="n">x</span>: <span class="nc">i8x16</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">..</span><span class="p">.;</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">bits</span>: <span class="nc">m1x16</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="n">splat</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">result</span>: <span class="kt">u16</span> <span class="o">=</span><span class="w"> </span><span class="n">bits</span><span class="p">.</span><span class="n">to_int</span><span class="p">();</span><span class="w"></span>
</code></pre></div>



<a name="212510177"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212510177" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212510177">(Oct 07 2020 at 02:52)</a>:</h4>
<p>i think avx512 actually has masks that aren't 512 bits, so... dunno how we wanna handle that whole thing</p>



<a name="212511036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212511036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212511036">(Oct 07 2020 at 03:12)</a>:</h4>
<p>I vote for <code>m1x64</code> for a 64-lane 1-bit-per-lane mask.</p>



<a name="212511100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212511100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212511100">(Oct 07 2020 at 03:14)</a>:</h4>
<p>avx512 is not the only one that uses 1-bit per lane masks: RISC-V V, Libre-SOC's SimpleV, and probably more do as well.</p>



<a name="212511105"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212511105" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212511105">(Oct 07 2020 at 03:14)</a>:</h4>
<p>AMDGPU too.</p>



<a name="212511122"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212511122" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212511122">(Oct 07 2020 at 03:15)</a>:</h4>
<p>i guess things like <code>impl From&lt;m8x16&gt; for m1x16</code> would be a sane place to use movemask intrinsics. anyway, that wasn't <em>really</em> my point.</p>
<p>not really sure if you'd ever use a m1xN mask is besides just to turn it into an integer tho</p>



<a name="212511204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212511204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212511204">(Oct 07 2020 at 03:17)</a>:</h4>
<p>Single bit masks would also be useful for detecting overflow, as that's what the llvm function uses</p>



<a name="212511952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212511952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212511952">(Oct 07 2020 at 03:36)</a>:</h4>
<p>I should also note that "AVX512" is not "AVX512"... there is AVX512F and then all the additional extension featuresets on top of it.</p>



<a name="212511991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212511991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212511991">(Oct 07 2020 at 03:36)</a>:</h4>
<p><span class="user-mention silent" data-user-id="209168">Thom Chiovoloni</span> <a href="#narrow/stream/257879-project-portable-simd/topic/What.20core.3A.3Aarch.20users.20need.20from.20std.3A.3Asimd/near/212511122">said</a>:</p>
<blockquote>
<p>not really sure if you'd ever use a m1xN mask is besides just to turn it into an integer tho</p>
</blockquote>
<p>maybe not on code designed for x86 without avx512, but other architectures use m1xL masks instead of mNxL masks since it's more power-efficient. At least RISC-V V and SimpleV do that.</p>



<a name="212512004"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212512004" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212512004">(Oct 07 2020 at 03:36)</a>:</h4>
<p>Hm, this is a different topic.</p>



<a name="212512011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212512011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212512011">(Oct 07 2020 at 03:37)</a>:</h4>
<p>AVX512 is a nice shorthand for AVX512F and all the other instructions that use <code>zmm</code> registers</p>



<a name="212512057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212512057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212512057">(Oct 07 2020 at 03:38)</a>:</h4>
<p>Here we go.</p>



<a name="212512069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212512069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212512069">(Oct 07 2020 at 03:38)</a>:</h4>
<p>This is what I was referring to with 1-bit masks being used for overflow: <a href="https://llvm.org/docs/LangRef.html#llvm-sadd-with-overflow-intrinsics">https://llvm.org/docs/LangRef.html#llvm-sadd-with-overflow-intrinsics</a></p>
<p>I think I'd be ok with adding them if it's not only used for a single thing</p>



<a name="212512071"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212512071" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212512071">(Oct 07 2020 at 03:38)</a>:</h4>
<p>Yeah, it is.</p>



<a name="212512148"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212512148" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212512148">(Oct 07 2020 at 03:40)</a>:</h4>
<p>It may make sense to provide ops that work with both lane-width-masks and m1xN masks with the understanding that one will be faster than the other depending on the architecture, and the other will likely do a narrowing or widening op</p>



<a name="212512160"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212512160" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212512160">(Oct 07 2020 at 03:41)</a>:</h4>
<p>It may also not make sense to do this, I haven't actually looked at RISC-V's SIMD or any other arch that actually uses them</p>



<a name="212512233"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212512233" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212512233">(Oct 07 2020 at 03:43)</a>:</h4>
<p>the common cases for movemask is basically e.g. <code>_mm_movemask_ps(_mm_cmpeq_ps(a, b))</code>. this gives you a 4-bit value that tells you which lanes were equal. often you just do something like test the result for <code>0b1111</code> or <code>0</code>, but you can get <a href="https://github.com/thomcc/bad3d/blob/master/t3m/src/simd.rs#L359-L366">more clever</a>.</p>
<p>i guess for avx512foo the return value would be potentially a 64 bit integer? i'm a little confused and suspect i may have explained something poorly at some point</p>



<a name="212512284"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212512284" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212512284">(Oct 07 2020 at 03:44)</a>:</h4>
<p>I just felt like I should note that complication re: AVX512 just in case anyone got too comfortable with treating them all as a single set, since it matters for discussing intrinsics and such that aren't literally in AVX512F.</p>



<a name="212512287"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212512287" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212512287">(Oct 07 2020 at 03:44)</a>:</h4>
<p>note that the _mm_cmpeq operation returns a e.g. m32x4 there</p>



<a name="212512444"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212512444" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212512444">(Oct 07 2020 at 03:48)</a>:</h4>
<blockquote>
<p>It may make sense to provide ops that work with both lane-width-masks and m1xN masks with the understanding that one will be faster than the other depending on the architecture</p>
</blockquote>
<p>the 1bit mask is strictly an output for the x86 stuff i'm aware of. i mean, you could reverse the operation, but it would have to be done manually.</p>
<p>so that makes sense iff another target uses 1bit masks for input (is this true?)</p>



<a name="212512449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212512449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212512449">(Oct 07 2020 at 03:48)</a>:</h4>
<p>The plan for SimpleV is that comparing <code>Tx64</code> values would return a 64-bit value in an integer register -- similar to AVX512F's compares, except that they store the result in the <code>kN</code> mask registers.</p>



<a name="212512462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212512462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212512462">(Oct 07 2020 at 03:49)</a>:</h4>
<p>SimpleV and AVX512 do use 1-bit masks for predicated execution.</p>



<a name="212512518"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212512518" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212512518">(Oct 07 2020 at 03:50)</a>:</h4>
<p>and before AVX512 it seems to map to movemask.  I wonder if NEON has any comparable instruction(s)</p>



<a name="212512529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212512529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212512529">(Oct 07 2020 at 03:50)</a>:</h4>
<blockquote>
<p>I wonder if NEON has any comparable instruction(s)</p>
</blockquote>
<p><a href="https://github.com/DLTcollab/sse2neon">https://github.com/DLTcollab/sse2neon</a> is usually how i answer this question</p>



<a name="212512557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212512557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212512557">(Oct 07 2020 at 03:51)</a>:</h4>
<p><a href="https://github.com/DLTcollab/sse2neon/blob/master/sse2neon.h#L2056">https://github.com/DLTcollab/sse2neon/blob/master/sse2neon.h#L2056</a></p>
<blockquote>
<p>NEON does not provide this method</p>
</blockquote>



<a name="212512632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212512632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212512632">(Oct 07 2020 at 03:53)</a>:</h4>
<p>this is an extremely powerful repo thank you.</p>



<a name="212512633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212512633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212512633">(Oct 07 2020 at 03:53)</a>:</h4>
<p>it's tricky to think what good more broad API for this is. most cases (aside from weirdos like me using it as an index) is to answer "which lanes between these two vectors pass the given test" efficiently</p>



<a name="212512684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212512684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212512684">(Oct 07 2020 at 03:54)</a>:</h4>
<p>It's radiating some intensely (cursed | blessed) energy.</p>



<a name="212512685"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212512685" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212512685">(Oct 07 2020 at 03:54)</a>:</h4>
<p>I'm curious what llvm produces for <code>fcmp</code> etc on NEON</p>



<a name="212512689"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212512689" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212512689">(Oct 07 2020 at 03:54)</a>:</h4>
<p>(the LLVM instruction <code>fcmp</code>, I mean)</p>



<a name="212512706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212512706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212512706">(Oct 07 2020 at 03:55)</a>:</h4>
<p>I would _hope_ that movemask is a specific case of <code>icmp</code></p>



<a name="212512812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212512812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212512812">(Oct 07 2020 at 03:58)</a>:</h4>
<blockquote>
<p>I would _hope_ that movemask is a specific case of icmp</p>
</blockquote>
<p>yeah, i still think i haven't explained what movemask does well enough. it's not the actual comparison, it's the <code>mLxN</code> =&gt; <code>m1xN</code> function you use so that you can easily look at the result of the comparison</p>



<a name="212512816"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212512816" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212512816">(Oct 07 2020 at 03:59)</a>:</h4>
<p>i'm pretty confident that you couldn't implement it as a icmp</p>



<a name="212512894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212512894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212512894">(Oct 07 2020 at 04:00)</a>:</h4>
<p>e.g. <code>fn m32x4::all_zero(self) -&gt; bool</code> would be <code>_mm_movemask_ps(transmute(self)) == 0</code><br>
and <code>fn m32x4::all_ones(self) -&gt; bool</code> would be <code>_mm_movemask_ps(transmute(self)) == 0b1111</code></p>



<a name="212512991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212512991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212512991">(Oct 07 2020 at 04:02)</a>:</h4>
<p>outside of overly clever code, it's purely a thing you use for inspecting a <code>mKxN</code> that came from a comparison</p>



<a name="212513011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212513011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212513011">(Oct 07 2020 at 04:03)</a>:</h4>
<p>(sorry if we <em>are</em> on the same page on this and i'm overexplaining, it just didn't feel that way)</p>



<a name="212513169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212513169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212513169">(Oct 07 2020 at 04:05)</a>:</h4>
<p>maybe I'm just tired, but I think <code>icmp lt &lt;i32 x 4&gt; 0 x</code>should generate movemask if the compiler is smart?</p>



<a name="212513372"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212513372" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212513372">(Oct 07 2020 at 04:08)</a>:</h4>
<p>oh, maybe. i guess that would return &lt;i1 x 4&gt; ? i'd expect llvm to possibly try to avoid the movemask since it is another instruction on top of the compare, and you don't always need it. my understanding of something like &lt;i1 x 4&gt; is that it's allowed to use more space than 1 bit per lane?</p>



<a name="212513394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212513394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212513394">(Oct 07 2020 at 04:08)</a>:</h4>
<p>similar to how bool is i1 and is actually 8 bits. but perhaps it works differently for vectors</p>



<a name="212513414"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212513414" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212513414">(Oct 07 2020 at 04:09)</a>:</h4>
<p>as part of legalization/instruction selection/something else for x86, <code>&lt;i1 x 4&gt;</code> would be expanded to <code>&lt;i32 x 4&gt;</code>.</p>



<a name="212513426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212513426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212513426">(Oct 07 2020 at 04:09)</a>:</h4>
<p>Well here it's a constant 0,so I think it would produce it. On another arch it will probably just do a compare</p>



<a name="212513471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212513471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212513471">(Oct 07 2020 at 04:10)</a>:</h4>
<p>or <code>&lt;i64 x 4&gt;</code> -- whatever matches the lane width of the thing it's used with.</p>



<a name="212513483"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212513483" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212513483">(Oct 07 2020 at 04:10)</a>:</h4>
<p>Are you sure that llvm does that, and not just rustc?  I figured rustc is sign extending the mask (which the compiler optimizes out)</p>



<a name="212513506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212513506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212513506">(Oct 07 2020 at 04:11)</a>:</h4>
<p>the important part is that LLVM's layout for <code>&lt;i1 x 8&gt;</code> is not the same as <code>i8</code>.</p>



<a name="212513510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212513510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212513510">(Oct 07 2020 at 04:11)</a>:</h4>
<p>so it doesn't ever convert it to a single integer.</p>



<a name="212513512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212513512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212513512">(Oct 07 2020 at 04:12)</a>:</h4>
<p>What is the layout?</p>



<a name="212513554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212513554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212513554">(Oct 07 2020 at 04:12)</a>:</h4>
<p>yeah. if you actually do need to produce an i8 thats when llvm would have to emit a movemask. but that pretty much might be limited to "when the user uses a movemask intrinsic"</p>



<a name="212513555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212513555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212513555">(Oct 07 2020 at 04:12)</a>:</h4>
<p>I guess the alignment of i1 is a byte?</p>



<a name="212513589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212513589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212513589">(Oct 07 2020 at 04:13)</a>:</h4>
<p>i'd hope that if <code>fcmp</code> on a vector produces <code>&lt;i1 x N&gt;</code> then it would be valid to represent <code>&lt;i1 x N&gt;</code> as just the result of the comparison operation. but i guess i can see why that might not be possible.</p>



<a name="212513594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212513594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212513594">(Oct 07 2020 at 04:13)</a>:</h4>
<p>I think it doesn't really have a defined layout, it just gets expanded to <code>&lt;i32 x 4&gt;</code> if used to mask another <code>&lt;i32 x 4&gt;</code></p>



<a name="212513651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212513651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212513651">(Oct 07 2020 at 04:14)</a>:</h4>
<p>Right, but I'm guessing if we explicitly pack it into an m1xN it may optimize correctly</p>



<a name="212513657"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212513657" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212513657">(Oct 07 2020 at 04:14)</a>:</h4>
<p>At least I'd like to see</p>



<a name="212513772"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212513772" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212513772">(Oct 07 2020 at 04:16)</a>:</h4>
<p>what I expect if you tried to use a <code>m1xN</code> on x86 is LLVM would expand it to <code>m32xN</code> or whatever other lane size we use it with. The actual representation in memory is probably something like <code>m8xN</code></p>



<a name="212513867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212513867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212513867">(Oct 07 2020 at 04:18)</a>:</h4>
<p>i doubt it would use a movemask since the actual semantics of that instruction are that it only operates on the MSB of each lane. so you'd have to be careful to ensure your explicit packing behaved that way. we can know all bits are the same in a land in a <code>mLxN</code> because of type-level guarantees but idk if llvm can know</p>



<a name="212513976"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212513976" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212513976">(Oct 07 2020 at 04:21)</a>:</h4>
<p>I think what <code>packed_simd</code> did was just say "there's a truthy value here" and the rest is unspecified.</p>
<p>We might have to have a bit of a concession against simplicity and either use two mask types or make mask value content way more vague.</p>



<a name="212514034"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514034" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514034">(Oct 07 2020 at 04:23)</a>:</h4>
<p>i think the packed simd approach is fine, i also think there should be a way to get it as a 1-bit-per-lane mask (which would use movemask on x86 or a fallback elsewhere) but that's in the category of "apis only worth exposing only because it's very efficient on some platform".</p>



<a name="212514088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514088">(Oct 07 2020 at 04:24)</a>:</h4>
<p>actually "a truthy value" might be too vague — it is sometimes very useful to be able to actually use the comparison result, err, as a mask. i assume that's why we named them mask vectors (and not bool vectors) anyway.</p>



<a name="212514111"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514111" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514111">(Oct 07 2020 at 04:25)</a>:</h4>
<p><span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span> I am so confused.</p>



<a name="212514113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514113">(Oct 07 2020 at 04:25)</a>:</h4>
<p>So the problem is we can't just use movemask, whatever we do needs to be just LLVM intrinsics to ensure that everything codegens ok</p>



<a name="212514182"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514182" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514182">(Oct 07 2020 at 04:27)</a>:</h4>
<p><em>currently</em> the code in the stdsimd repo is all sorts of masks of specific widths. we should avoid building too much more on top of masks until the mask situation is clarified, which also means we can't implement comparisons and blends, which mostly means we can't implement most stuff.</p>
<p>So i guess this is accidentally a major blocking point.</p>
<p>What I personally want a mask to do, as a user, is be a "yes / no" per lane, and you can combine them lanewise like a bool, and then when you have the lane mask you want you use it to blend between two code paths.</p>
<p>are there additional requirements on the <em>purpose</em> of having a mask? or is that the basic idea regardless of the size/details of the mask types?</p>



<a name="212514251"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514251" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514251">(Oct 07 2020 at 04:29)</a>:</h4>
<p>I agree, I think that's all I generally want it to do as well</p>



<a name="212514378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514378">(Oct 07 2020 at 04:32)</a>:</h4>
<p>yes, that's correct. I also think there should be something like</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">impl</span><span class="w"> </span><span class="n">m32x4</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="sd">/// Returns a 4-bit value containing a 1 for ever occupied lane in this mask</span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">to_int</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">u8</span> <span class="p">{</span><span class="w"> </span><span class="cm">/*... use movemask on x86, fallback elsewhere ...*/</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>

<p>for each mask type</p>
<p>i brought this up in the other topic as an example of an API which you probably wouldn't add except for the fact that it's extremely efficient on one of the platforms, and isn't <em>too</em> bad on the others. I think it fits here, but it's hardly important enough to impact the whole design (even though it's ubiquitous in actual SSE code).</p>



<a name="212514391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514391">(Oct 07 2020 at 04:33)</a>:</h4>
<p>i've always been told that movemask is actually quite inefficient and can quickly stall the simd pipeline, avoid it and such</p>



<a name="212514394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514394">(Oct 07 2020 at 04:33)</a>:</h4>
<p>Turns out I was wrong about <code>m1xN</code> on x86_64, the in-memory representation is <code>uN</code>:<br>
<a href="https://gcc.godbolt.org/z/994v1b">https://gcc.godbolt.org/z/994v1b</a></p>



<a name="212514402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514402">(Oct 07 2020 at 04:33)</a>:</h4>
<p>The problem is you can't, say, do that for m32x8, because that would be AVX which you don't necessarily have the target feature for</p>



<a name="212514450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514450">(Oct 07 2020 at 04:34)</a>:</h4>
<p>That's good news</p>



<a name="212514451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514451">(Oct 07 2020 at 04:34)</a>:</h4>
<blockquote>
<p>i've always been told that movemask is actually quite inefficient and can quickly stall the simd pipeline, avoid it and such</p>
</blockquote>
<p>i mean it has a data dep on the mask used as input but its still only 1 or 2 cycles pretty much everywhere. it's better to avoid since generally if you use it you're about to branch though</p>



<a name="212514469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514469">(Oct 07 2020 at 04:35)</a>:</h4>
<p>I say we _try_ implementing 1-bit masks and the associated comparisons etc and if it codegens as expected then it's up to the user to pick the one they want</p>



<a name="212514472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514472">(Oct 07 2020 at 04:35)</a>:</h4>
<p>Yeah, so one minor constraint is that when you have N lane vectors, you need an N lane mask type, so at the wider types we'd need like a u64 as the mask output to bit pack all the lanes in.</p>



<a name="212514473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514473">(Oct 07 2020 at 04:35)</a>:</h4>
<p>it's also always better to use the comparison result to select directly if possible, it's just that only applies to algorithms where that's relevant</p>



<a name="212514597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514597">(Oct 07 2020 at 04:39)</a>:</h4>
<p><del>is there a way we can get away with not having an explicit movemask API at all and just make the operations that it describes implicitly happen</del></p>



<a name="212514605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514605">(Oct 07 2020 at 04:40)</a>:</h4>
<p>uhhhhh, honestly, probably</p>



<a name="212514657"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514657" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514657">(Oct 07 2020 at 04:40)</a>:</h4>
<p>Yeah I think so too haha. A comparison api should be sufficient</p>



<a name="212514660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514660">(Oct 07 2020 at 04:41)</a>:</h4>
<blockquote>
<p>I say we _try_ implementing 1-bit masks and the associated comparisons etc and if it codegens as expected then it's up to the user to pick the one they want</p>
</blockquote>
<p>err, why? i'm pretty sure <code>simd_{eq,lt,gt,...}</code> functions return a wider mask directly. converting to a 1 bit per lane mask eagerly seems bad because:</p>
<ol>
<li>on platforms without a movemask equivalent it's wasteful since you use other operations to test the mask values</li>
<li>you have to expand the one bit mask into a wider mask if it gets used for, well, masking, and IDK if any arch can do this efficiently</li>
</ol>



<a name="212514663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514663">(Oct 07 2020 at 04:41)</a>:</h4>
<p>okay so,<br>
pretend I am a very small overexcited child that has somehow wound up on a standards committee,<br>
I grasp what masking is for abstractly, but what exactly is <code>_mm_movemask_ps</code> specifically for?</p>



<a name="212514673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514673">(Oct 07 2020 at 04:41)</a>:</h4>
<p>inspecting the result of the a comparison operation</p>



<a name="212514674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514674">(Oct 07 2020 at 04:41)</a>:</h4>
<p><span class="user-mention" data-user-id="209168">@Thom Chiovoloni</span> I'm suggesting using the llvm intrinsics, not the rustc intrinsics</p>



<a name="212514723"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514723" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514723">(Oct 07 2020 at 04:42)</a>:</h4>
<p>So movemask_ps converts <code>__m128</code> (think <code>f32x4</code>) that stores a truthy value in each lane into an <code>i32</code> with the lowest 4 bits set to 0 or 1, and all other bits 0. This lets you easily inspect the mask register in a more normal way because now it's just an i32</p>



<a name="212514729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514729">(Oct 07 2020 at 04:42)</a>:</h4>
<p>Is it <code>eq</code> or <code>cmp</code>?<br>
<code>eq</code> is only 1 bit, so it shouldn't be?<br>
ahhhh</p>



<a name="212514730"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514730" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514730">(Oct 07 2020 at 04:43)</a>:</h4>
<p>I think we're maybe a little too focused on movemask specifically. AVX512 has a whole suite of comparisons on 1-bit masks, right?</p>



<a name="212514741"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514741" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514741">(Oct 07 2020 at 04:43)</a>:</h4>
<p>Movemask is just one particular instruction that can be used for that API for SSE and AVX</p>



<a name="212514743"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514743" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514743">(Oct 07 2020 at 04:43)</a>:</h4>
<p>yes i was told that avx512 has entirely special registers for masks that need their own handling.</p>



<a name="212514788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514788">(Oct 07 2020 at 04:44)</a>:</h4>
<p>okay, so <code>_mm_movemask_ps</code> is in fact 1 bit per lane,<br>
are there any APIs which expose masks which aren't 1 bit per lane?</p>



<a name="212514791"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514791" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514791">(Oct 07 2020 at 04:44)</a>:</h4>
<p>Comparisons?</p>



<a name="212514796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514796">(Oct 07 2020 at 04:44)</a>:</h4>
<p>the standard "mask" values you get from comparisons are the exact same size as the types you're comparing. The movemask operation collapses that from x bits per lane to 1 bit per lane.</p>



<a name="212514797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514797">(Oct 07 2020 at 04:44)</a>:</h4>
<p>Everything else in SSE, AVX, NEON</p>



<a name="212514800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514800">(Oct 07 2020 at 04:45)</a>:</h4>
<p>almost every vector comparison API in hardware returns a vector of the same size with all-bits-set in any lanes where the comparison passed, and no-bits-set where it failed</p>



<a name="212514809"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514809" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514809">(Oct 07 2020 at 04:45)</a>:</h4>
<p>Movemask and AVX512 are special here, but maybe not so special looking at RISC-V</p>



<a name="212514815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514815">(Oct 07 2020 at 04:45)</a>:</h4>
<p>Okay, so <em>abstractly</em>,<br>
as in pure information theory level,<br>
is it ever not 1 bit per lane?</p>



<a name="212514818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514818">(Oct 07 2020 at 04:45)</a>:</h4>
<p>No</p>



<a name="212514823"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514823" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514823">(Oct 07 2020 at 04:45)</a>:</h4>
<p>always true or false per lane</p>



<a name="212514824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514824">(Oct 07 2020 at 04:45)</a>:</h4>
<p><strong>Cool.</strong></p>



<a name="212514870"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514870" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514870">(Oct 07 2020 at 04:46)</a>:</h4>
<p>Then our type is Mask x Width, as I understand it.</p>



<a name="212514877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514877">(Oct 07 2020 at 04:46)</a>:</h4>
<p>this is super useful for a lot of things (selects and such), but different hardware has different strategies for answering questions like "did all lanes pass the comparison".</p>
<p>for x86 you do this with movemask<br>
for neon you do something like check fi the minimum value in the mask vector is all-bits-set</p>



<a name="212514879"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514879" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514879">(Oct 07 2020 at 04:46)</a>:</h4>
<p><em>sorta</em> (@ jub)</p>



<a name="212514890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514890">(Oct 07 2020 at 04:47)</a>:</h4>
<p>I think we can't hide away the mask width become some architectures support both</p>



<a name="212514893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514893">(Oct 07 2020 at 04:48)</a>:</h4>
<p>yeah that's the heart of it.</p>



<a name="212514932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514932">(Oct 07 2020 at 04:48)</a>:</h4>
<p>And you may want to transmute it, I guess</p>



<a name="212514940"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514940" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514940">(Oct 07 2020 at 04:48)</a>:</h4>
<p>I am not sure we cannot if we provide transformation functions for the different arch mask types.</p>



<a name="212514941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514941">(Oct 07 2020 at 04:48)</a>:</h4>
<p>Particularly transmuting 1 bit masks to integers for table lookups</p>



<a name="212514944"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514944" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514944">(Oct 07 2020 at 04:48)</a>:</h4>
<p><span class="user-mention" data-user-id="281757">@Jubilee</span> some mask values are, in hardware, &gt;1 bits per lane, and some are actually in hardware 1 bit per lane, and we can't paper over that difference. we probably need to expose both systems, horrible as that might be.</p>



<a name="212514949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514949">(Oct 07 2020 at 04:49)</a>:</h4>
<p>"Do not transmute this, plz."</p>



<a name="212514953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514953">(Oct 07 2020 at 04:49)</a>:</h4>
<p>hmmmmmmmm.</p>



<a name="212514955"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514955" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514955">(Oct 07 2020 at 04:49)</a>:</h4>
<p>I actually don't think it's particularly awful</p>



<a name="212514961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514961">(Oct 07 2020 at 04:49)</a>:</h4>
<p>You can then just use cfg or whatever to select which you prefer</p>



<a name="212514963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212514963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212514963">(Oct 07 2020 at 04:50)</a>:</h4>
<p>Same as number of lanes</p>



<a name="212515013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515013">(Oct 07 2020 at 04:50)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20movemasquerade/near/212514402">said</a>:</p>
<blockquote>
<p>The problem is you can't, say, do that for m32x8, because that would be AVX which you don't necessarily have the target feature for</p>
</blockquote>
<p>LLVM seems to work fine when you tell it to not use AVX:<br>
<a href="https://gcc.godbolt.org/z/WTEdT4">https://gcc.godbolt.org/z/WTEdT4</a></p>



<a name="212515016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515016">(Oct 07 2020 at 04:50)</a>:</h4>
<p>(I would hope some SIMD traits make it easier to write generic)</p>



<a name="212515026"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515026" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515026">(Oct 07 2020 at 04:50)</a>:</h4>
<p>particularly, since we're promising that <code>core::simd</code> is easily interacting with <code>core::arch</code>, we need to be fairly concrete about the types because people need to concretely know what <code>core::arch</code> thing they line up with on a particular arch (and the answer might be "nothing on this particular arch quite matches that <code>core::simd</code> type, don't think about it too hard")</p>
<p>eg, f32x8 has no 100% mapping for neon, so we tell you to use [vf32x4;2] maybe</p>



<a name="212515042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515042">(Oct 07 2020 at 04:51)</a>:</h4>
<p>anyway i brought up movemask explicitly because its a bit of a wonky api.</p>
<p>my point was that that's honestly fine, it doesn't have to be a major part of the comparison/masking API, just one extra function on mask types that's exposed. this follows the logic of (from <span class="user-mention" data-user-id="239881">@Josh Triplett</span>'s comment in the other thread).</p>
<blockquote>
<p>if something is fast in one vector instruction set, it's worth exposing, even if other instruction sets have to write it out as a series of instructions.</p>
</blockquote>
<p>which imo is worth doing, at least for the cases where it's not too burdensome</p>



<a name="212515051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515051">(Oct 07 2020 at 04:51)</a>:</h4>
<p><span class="user-mention" data-user-id="229517">@Jacob Lifshay</span> that's how I think it should be done, I meant we can't explicitly use the naskmove instruction</p>



<a name="212515108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515108">(Oct 07 2020 at 04:52)</a>:</h4>
<p>I'm also very happy that icmp codegens correctly in that case</p>



<a name="212515120"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515120" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515120">(Oct 07 2020 at 04:53)</a>:</h4>
<p>It's promising that the API should "just work"</p>



<a name="212515128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515128">(Oct 07 2020 at 04:53)</a>:</h4>
<p>So, <em>resolved</em> (?) that mask types shal be convertable to integers via a method on the type.</p>
<p>question: can we say the output type is always u64? or do we usually want u32 and then u64 as the output type only when there's actually 64 lanes?</p>



<a name="212515168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515168">(Oct 07 2020 at 04:54)</a>:</h4>
<p>Though, if you want to see some truly awful code: <a href="https://gcc.godbolt.org/z/14xc3a">https://gcc.godbolt.org/z/14xc3a</a></p>



<a name="212515188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515188">(Oct 07 2020 at 04:55)</a>:</h4>
<p>Do we really just want them convertible? I would think we specifically want to duplicate the mask api for both lane-width and 1-bit masks, unless I'm misunderstanding</p>



<a name="212515203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515203">(Oct 07 2020 at 04:55)</a>:</h4>
<p>Rust offers all sorts of conversions that aren't bit-level transmutes.</p>



<a name="212515243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515243">(Oct 07 2020 at 04:56)</a>:</h4>
<p>well, you're just converting it to a normal int, not a special second mask type.</p>



<a name="212515254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515254">(Oct 07 2020 at 04:56)</a>:</h4>
<p>So, what happens when one architecture stores the bits where lane 0 corresponds to the MSB and other architectures has lane 0 correspond to the LSB?</p>



<a name="212515259"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515259" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515259">(Oct 07 2020 at 04:56)</a>:</h4>
<p>Sorry, what I meant was that some architectures support a whole variety of 1-bit mask operations, so we need to support those too I think</p>



<a name="212515263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515263">(Oct 07 2020 at 04:57)</a>:</h4>
<p>I am thinking I would <strong>like</strong> to solve this with a single somewhat abstract type that offers hardware-level transformation functions and maybe attributes, here, so that when it's not needed to go to <code>std::arch</code>, you don't have to worry about what type it is at all, and LLVM just does whatever seems correct, and maybe you decorate some things with an extra attribute to make sure they use the "right" mask type.</p>



<a name="212515276"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515276" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515276">(Oct 07 2020 at 04:57)</a>:</h4>
<p><span class="user-mention" data-user-id="229517">@Jacob Lifshay</span> the "spec" for this would be that bit 0 is lane 0, bit 1 is lane 1, etc, whatever that means happens on the local arch.</p>



<a name="212515326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515326">(Oct 07 2020 at 04:58)</a>:</h4>
<p>I don't understand how it can be a single type if AVX512 has operations that would work with both say m1x8 and m32x8</p>



<a name="212515340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515340">(Oct 07 2020 at 04:59)</a>:</h4>
<p>they don't work with both types, i think</p>



<a name="212515341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515341">(Oct 07 2020 at 04:59)</a>:</h4>
<p><span class="user-mention" data-user-id="281757">@Jubilee</span>  That type could be target calling convention specific to avoid unnecessary <code>pmovmskb</code> on x86 or the probably even worse code needed to convert from an int back to a full vector</p>



<a name="212515346"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515346" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515346">(Oct 07 2020 at 04:59)</a>:</h4>
<p>All I mean is it's a user's decision which to use in that case</p>



<a name="212515406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515406">(Oct 07 2020 at 05:00)</a>:</h4>
<p>So I don't think we should attempt to hide away the mask width, there are reasons to use both</p>



<a name="212515422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515422">(Oct 07 2020 at 05:00)</a>:</h4>
<p>from what i saw of avx512 they weren't flexible on mask type</p>



<a name="212515427"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515427" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515427">(Oct 07 2020 at 05:00)</a>:</h4>
<p>like, a given op used a given mask type, not "whatever type of mask you want"</p>



<a name="212515433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515433">(Oct 07 2020 at 05:00)</a>:</h4>
<p>eg: <code>void _mm512_2intersect_epi32 (__m512i a, __m512i b, __mmask16* k1, __mmask16* k2)</code></p>



<a name="212515441"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515441" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515441">(Oct 07 2020 at 05:01)</a>:</h4>
<p>It's not hiding the mask width, it's just ignoring it when it isn't relevant. <span aria-label="shrug" class="emoji emoji-1f937" role="img" title="shrug">:shrug:</span></p>



<a name="212515453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515453">(Oct 07 2020 at 05:01)</a>:</h4>
<p>fine details are sadly always relevent</p>



<a name="212515460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515460">(Oct 07 2020 at 05:01)</a>:</h4>
<p>that is why we could allow programmers to add the amount of salience that they personally need.</p>



<a name="212515509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515509">(Oct 07 2020 at 05:02)</a>:</h4>
<p>Right, but there are choices such as _mm_cmp_ps and _mm_cmp_mask_ps</p>



<a name="212515511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515511">(Oct 07 2020 at 05:02)</a>:</h4>
<p>Not sure if I got those names right</p>



<a name="212515525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515525">(Oct 07 2020 at 05:03)</a>:</h4>
<p>AVX512 adds the packed comparisons in addition to the original wide mask comparisons</p>



<a name="212515529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515529">(Oct 07 2020 at 05:03)</a>:</h4>
<p>well, following LLVM's precedent, I vote for <code>m1xN</code> as the default representation when not being passed as function parameters or return values or being stored in memory. LLVM is most likely to optimize that type correctly, since it's what it uses internally.</p>



<a name="212515554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515554">(Oct 07 2020 at 05:03)</a>:</h4>
<p>That's also a possibility</p>



<a name="212515555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515555">(Oct 07 2020 at 05:03)</a>:</h4>
<p>"when not being passed as function parameters or return values" is an odd way to put it.</p>



<a name="212515557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515557">(Oct 07 2020 at 05:04)</a>:</h4>
<p><span class="user-mention" data-user-id="229517">@Jacob Lifshay</span> what does LLVM do if you want to use the comparison result as a mask in a further operation?</p>



<a name="212515634"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515634" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515634">(Oct 07 2020 at 05:05)</a>:</h4>
<p>also what is the actual binary representation of m1xN ? is it 1-bit-per-lane? because that truly seems like the worst of all worlds. (disasterous to have to splat out if you need a mask, forces movemask or movemask-equivalent everywhere even when you don't need 1 bit per lane)</p>



<a name="212515650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515650">(Oct 07 2020 at 05:05)</a>:</h4>
<p>i genuinely think the design we have now, and that packed_simd uses, is pretty good? it's heading in the right direction anyway.</p>



<a name="212515716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515716">(Oct 07 2020 at 05:06)</a>:</h4>
<p>Remember that it's just a type in llvm, it doesn't necessarily correspond to actual memory layout</p>



<a name="212515732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515732">(Oct 07 2020 at 05:06)</a>:</h4>
<p>yeah, but if we're going to say "m1xN is the default representation", that <em>is</em> a representation</p>



<a name="212515744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515744">(Oct 07 2020 at 05:07)</a>:</h4>
<p>or else i don't know what that statement means</p>



<a name="212515749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515749">(Oct 07 2020 at 05:07)</a>:</h4>
<p>That's true</p>



<a name="212515759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515759">(Oct 07 2020 at 05:07)</a>:</h4>
<p>I think Jacob may have meant API / logical representation.</p>



<a name="212515769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515769">(Oct 07 2020 at 05:07)</a>:</h4>
<p>Part of the reason I don't think we should try to go too hard on layout here is precisely because this is not the first time Rust has a highly unspecified layout.</p>



<a name="212515821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515821">(Oct 07 2020 at 05:08)</a>:</h4>
<p>yeah but there's <em>much</em> gnashing of teeth in the unsafe community every time things are less specified</p>



<a name="212515827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515827">(Oct 07 2020 at 05:08)</a>:</h4>
<p>Is there any reason we can't have both parts of the api? For example <code>eq</code> and <code>eq_packed</code>, or whatever we want to call it</p>



<a name="212515835"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515835" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515835">(Oct 07 2020 at 05:08)</a>:</h4>
<p>There is, and sometimes you have to deal.</p>



<a name="212515843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515843">(Oct 07 2020 at 05:09)</a>:</h4>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> You are going to get someone who gets them backwards every day.</p>



<a name="212515849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515849">(Oct 07 2020 at 05:09)</a>:</h4>
<p>i like caleb's plan</p>



<a name="212515865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515865">(Oct 07 2020 at 05:09)</a>:</h4>
<p>I agree it's slightly confusing, but it looks like intel already uses both, and other architectures aren't consistent</p>



<a name="212515908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515908">(Oct 07 2020 at 05:10)</a>:</h4>
<p>ALSO, thom's plan: unpacked masks that simply also have a method to pack them down</p>



<a name="212515920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515920">(Oct 07 2020 at 05:10)</a>:</h4>
<p>...I think trying to specify this at this moment is a mistake.</p>



<a name="212515923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515923">(Oct 07 2020 at 05:10)</a>:</h4>
<p><span class="user-mention" data-user-id="281757">@Jubilee</span> genuinely unsure if an API that's largely for helping people write explicitly optimized/tuned code is the right place to be super handwavy about data layout tbh</p>



<a name="212515940"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515940" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515940">(Oct 07 2020 at 05:11)</a>:</h4>
<p>I was not proposing being handwavey.</p>



<a name="212515946"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515946" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515946">(Oct 07 2020 at 05:11)</a>:</h4>
<p>well, promising nothing then</p>



<a name="212515956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515956">(Oct 07 2020 at 05:11)</a>:</h4>
<p>I was not proposing that either, just no one read what I said.</p>



<a name="212515964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515964">(Oct 07 2020 at 05:11)</a>:</h4>
<p>I think considering the packed masks are specifically useful for indexing tables and the wide masks are specifically useful for transmuting both are probably necessary</p>



<a name="212515970"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212515970" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212515970">(Oct 07 2020 at 05:11)</a>:</h4>
<blockquote>
<p>sometimes you have to deal.</p>
</blockquote>
<p>i was responding to this</p>



<a name="212516046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516046">(Oct 07 2020 at 05:13)</a>:</h4>
<p>If you try to offer two types on the assumption that will be enough that will break if another architecture does not use either of them, and now you need 3.</p>



<a name="212516049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516049">(Oct 07 2020 at 05:13)</a>:</h4>
<p>wide masks are also useful for stuff like selecting lanes between two vectors and stuff. you use them all the time if you're trying to avoid branching in simd code.</p>



<a name="212516053"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516053" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516053">(Oct 07 2020 at 05:13)</a>:</h4>
<p>I would at least support an initial implementation to experiment with until we have a good reason to change it to something else</p>



<a name="212516065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516065">(Oct 07 2020 at 05:13)</a>:</h4>
<p><span class="user-mention silent" data-user-id="209168">Thom Chiovoloni</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20movemasquerade/near/212515557">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="229517">Jacob Lifshay</span> what does LLVM do if you want to use the comparison result as a mask in a further operation?</p>
</blockquote>
<p><a href="https://gcc.godbolt.org/z/s3r8hs">https://gcc.godbolt.org/z/s3r8hs</a></p>



<a name="212516067"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516067" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516067">(Oct 07 2020 at 05:13)</a>:</h4>
<p>Well, okay, mask values that are <code>maskBxL</code> for B bit elements and L count lanes. This <em>works</em> and we're very sure that it works because it's been used quite a bit, and it's simple to understand. <strong>Do we agree on this much?</strong></p>
<p>From there: <em>additional</em> ways to have a SIMD mask seem to me like they should be alternate ways without tainting the simplicity of the basic mask</p>



<a name="212516075"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516075" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516075">(Oct 07 2020 at 05:13)</a>:</h4>
<p><span class="user-mention" data-user-id="281757">@Jubilee</span> isn't that kind of the goal though? Support things that are generally available on many but not all architectures, and polyfill the rest</p>



<a name="212516125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516125">(Oct 07 2020 at 05:14)</a>:</h4>
<p>It is not handwavey to suggest a more abstract type that can be forced to solidify into a specific repr using provided transmutation functions.</p>



<a name="212516129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516129">(Oct 07 2020 at 05:14)</a>:</h4>
<p>I have material things to pack, so I should suppose I should get to that.</p>



<a name="212516134"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516134" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516134">(Oct 07 2020 at 05:14)</a>:</h4>
<p>i've had a Tim Rogers video paused for 30 minutes now</p>



<a name="212516144"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516144" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516144">(Oct 07 2020 at 05:15)</a>:</h4>
<p><span class="user-mention silent" data-user-id="229517">Jacob Lifshay</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20movemasquerade/near/212516065">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="209168">Thom Chiovoloni</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20movemasquerade/near/212515557">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="229517">Jacob Lifshay</span> what does LLVM do if you want to use the comparison result as a mask in a further operation?</p>
</blockquote>
<p><a href="https://gcc.godbolt.org/z/s3r8hs">https://gcc.godbolt.org/z/s3r8hs</a></p>
</blockquote>
<p>wow yikes, that's kinda what i was afraid of tbh</p>



<a name="212516168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516168">(Oct 07 2020 at 05:16)</a>:</h4>
<p>hence why I recommended it only be used for values inside functions, not for passing between functions or storing in memory</p>



<a name="212516206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516206">(Oct 07 2020 at 05:16)</a>:</h4>
<p>and convinces me that the use logic that "LLVM is most likely to optimize that type correctly, since it's what it uses internally." isn't really correct</p>



<a name="212516209"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516209" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516209">(Oct 07 2020 at 05:16)</a>:</h4>
<p>at least on x86</p>



<a name="212516217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516217">(Oct 07 2020 at 05:16)</a>:</h4>
<p>yeah i mean values inside functions don't have a representation so i have no opinion on that</p>



<a name="212516238"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516238" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516238">(Oct 07 2020 at 05:17)</a>:</h4>
<p><span class="user-mention silent" data-user-id="209168">Thom Chiovoloni</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20movemasquerade/near/212516206">said</a>:</p>
<blockquote>
<p>and convinces me that the use logic that "LLVM is most likely to optimize that type correctly, since it's what it uses internally." isn't really correct</p>
</blockquote>
<p>Hey, look at the return type of the <code>icmp</code> LLVM IR instruction: it's <code>&lt;16 x i1&gt;</code>. LLVM only supports <code>&lt;i1 x N&gt;</code> vectors as compare results and for the mask argument of the <code>select</code> instruction.</p>



<a name="212516239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516239">(Oct 07 2020 at 05:17)</a>:</h4>
<p>I don't even know what a value "in" a function but "not passed between" a function means, since you can only have a value from a literal or as the output of another function, so that other function passed it up to you</p>



<a name="212516240"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516240" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516240">(Oct 07 2020 at 05:17)</a>:</h4>
<p>like, whatever rustc wants to tell LLVM is fine by me, and the <code>f_sse_inlined</code> code says "telling it i1 vector" is more or less optimal so long as stuff stays inlined.</p>



<a name="212516298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516298">(Oct 07 2020 at 05:19)</a>:</h4>
<p>PS: I can't wait to have the next grand thread on how to handle immediate operations &lt;3</p>



<a name="212516301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516301">(Oct 07 2020 at 05:19)</a>:</h4>
<p><span class="user-mention" data-user-id="229517">@Jacob Lifshay</span> right the yikes is at the non-inlined version. the inlined version is basically ideal, but the non-inlined version is more or less exactly what i was worried about</p>



<a name="212516368"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516368" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516368">(Oct 07 2020 at 05:20)</a>:</h4>
<p><span class="user-mention silent" data-user-id="224471">Lokathor</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20movemasquerade/near/212516239">said</a>:</p>
<blockquote>
<p>I don't even know what a value "in" a function but "not passed between" a function means, since you can only have a value from a literal or as the output of another function, so that other function passed it up to you</p>
</blockquote>
<p>it means we add conversions at function boundaries and hope LLVM removes them when inlining.</p>



<a name="212516469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516469">(Oct 07 2020 at 05:22)</a>:</h4>
<p>Could you give a small example?</p>



<a name="212516486"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516486" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516486">(Oct 07 2020 at 05:23)</a>:</h4>
<p>Okay, let me say one last thing on this:<br>
Part of my reasoning is that if we have two type-incompatible mask width types then this <strong>badly</strong> hurts library support with a concern that they should not actually have to worry about, because now whenever the library... heck, whenever <em>we</em>... generate a mask type, then we have to decide which type comes back, which may not actually be optimized for a given architecture. However, a compiler in an application context can... what Jacob said.</p>



<a name="212516510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516510">(Oct 07 2020 at 05:23)</a>:</h4>
<p>anyway, given that overwhelmingly existing APIs represent comparison results the same (as masks of the same width) it's hard for me to see why we wouldn't assume that new APIs offering the same functionality would either do the same thing or have  a relatively cheap conversion.</p>
<p>the examples i've seen for different things, e.g. avx512, were really different APIs no?</p>



<a name="212516511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516511">(Oct 07 2020 at 05:23)</a>:</h4>
<p>A compiler can theoretically recognize that they should have been using a given mask type all along.</p>



<a name="212516582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516582">(Oct 07 2020 at 05:25)</a>:</h4>
<p>Well, I think that <em>part of</em> that is solved by having the wide masks bit pack to normal integers. Once you rip the info "from simd world" and just have a normal integer, then that's fine. That's not actually a whole other set of types we're dealing with. You can do whatever the heck you like with a <code>u32</code>, go nuts.</p>



<a name="212516588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516588">(Oct 07 2020 at 05:25)</a>:</h4>
<blockquote>
<p>Part of my reasoning is that if we have two type-incompatible mask width types</p>
</blockquote>
<p>do you consider the current API (e.g. <code>m32x4</code> and friends) to be this?</p>



<a name="212516649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516649">(Oct 07 2020 at 05:26)</a>:</h4>
<p>to be clear i would rather not have any support for e.g. <code>movemask</code> than have it require its own set of types. i think it's mostly relevant when porting algorithms, and can just be a inherent method that returns an integer.</p>



<a name="212516685"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516685" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516685">(Oct 07 2020 at 05:27)</a>:</h4>
<p>Yeah, "compress this to an integer" seems like a totally reasonable method.</p>



<a name="212516692"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516692" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516692">(Oct 07 2020 at 05:27)</a>:</h4>
<p>with or without hardware support</p>



<a name="212516764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516764">(Oct 07 2020 at 05:29)</a>:</h4>
<p>ideally the only time you use it is if you're porting code that expects hardware support or if your algorithm genuinely needs this operation and you can accept a less efficient operation when the hw support isn't there</p>



<a name="212516817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516817">(Oct 07 2020 at 05:30)</a>:</h4>
<p><span class="user-mention silent" data-user-id="224471">Lokathor</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20movemasquerade/near/212516469">said</a>:</p>
<blockquote>
<p>Could you give a small example?</p>
</blockquote>
<p><a href="https://gcc.godbolt.org/z/5Wxhhd">https://gcc.godbolt.org/z/5Wxhhd</a></p>
<p>I don't think it's possible to tell LLVM that a particular <code>&lt;16 x i8&gt;</code> is really <code>m8x16</code>, so it has to use a second compare instruction after the call.</p>



<a name="212516828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516828">(Oct 07 2020 at 05:31)</a>:</h4>
<p>ha, sorry, i meant could you show some rust code of what you meant.</p>



<a name="212516905"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516905" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516905">(Oct 07 2020 at 05:34)</a>:</h4>
<p><span class="user-mention silent" data-user-id="224471">Lokathor</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20movemasquerade/near/212516828">said</a>:</p>
<blockquote>
<p>ha, sorry, i meant could you show some rust code of what you meant.</p>
</blockquote>
<p>Oh:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">f</span><span class="p">(</span><span class="n">a</span>: <span class="nc">u8x16</span><span class="p">,</span><span class="w"> </span><span class="n">b</span>: <span class="nc">u8x16</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">maskx16</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="c1">// note maskx16 doesn't say which kind of mask it is</span>
<span class="w">    </span><span class="c1">// it's architecture specific with conversions to m1x16 and m8x16</span>
<span class="w">    </span><span class="k">return</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="n">b</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="212516953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212516953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212516953">(Oct 07 2020 at 05:35)</a>:</h4>
<p>it's mostly not visible from rust</p>



<a name="212517128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517128">(Oct 07 2020 at 05:38)</a>:</h4>
<p>hmm, so one complication feels like you might have, a number of mask values from more than one way</p>



<a name="212517150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517150">(Oct 07 2020 at 05:39)</a>:</h4>
<p>we could also just define <code>m8x16</code> to be either <code>&lt;16 x i1&gt;</code> or <code>&lt;16 x i8&gt;</code> depending on the architecture and define a <code>fullmask8x16</code> when the user explicitly wants <code>&lt;16 x i8&gt;</code></p>



<a name="212517151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517151">(Oct 07 2020 at 05:39)</a>:</h4>
<p>yeah so i think m1x16 is just <code>u16</code> honestly. but more importantly i think the LLVM examples kinda show that we do need to care about the width of the lanes</p>



<a name="212517212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517212">(Oct 07 2020 at 05:40)</a>:</h4>
<p>that is, say maskx4, that might be from f32x4 (128-bit) or f64x4 (256-bit), and it feels weird that you can't see the size there if you're going to use it as a blend. like blending f32x4 from a mask generated via a comparison between f64x4 sounds.... strange.</p>



<a name="212517231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517231">(Oct 07 2020 at 05:41)</a>:</h4>
<p>like, if i came across <a href="https://gcc.godbolt.org/z/7xoxab">https://gcc.godbolt.org/z/7xoxab</a> (which is a simple case — real code would likely have way more), it would would make me never want to use the API</p>



<a name="212517239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517239">(Oct 07 2020 at 05:41)</a>:</h4>
<p>i mean the f_sse function to be clear, the f_sse_inlined function is essentially optimal</p>



<a name="212517293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517293">(Oct 07 2020 at 05:42)</a>:</h4>
<p>i dont' really read intel asm, but that sure does look bad</p>



<a name="212517301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517301">(Oct 07 2020 at 05:42)</a>:</h4>
<p>theres a toggle for asm syntax style behind the gear.</p>



<a name="212517308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517308">(Oct 07 2020 at 05:43)</a>:</h4>
<p>no sorry, i mean that the only assembly i know is for arm</p>



<a name="212517313"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517313" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517313">(Oct 07 2020 at 05:43)</a>:</h4>
<p><span class="user-mention silent" data-user-id="224471">Lokathor</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20movemasquerade/near/212517212">said</a>:</p>
<blockquote>
<p>that is, say maskx4, that might be from f32x4 (128-bit) or f64x4 (256-bit), and it feels weird that you can't see the size there if you're going to use it as a blend. like blending f32x4 from a mask generated via a comparison between f64x4 sounds.... strange.</p>
</blockquote>
<p>That should be totally possible, it's what you get when vectorizing:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="n">a</span>: <span class="nc">f64x4</span><span class="p">;</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">b</span>: <span class="nc">f32x4</span><span class="p">;</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">c</span>: <span class="nc">f32x4</span><span class="p">;</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">d</span>: <span class="nc">f32x4</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Default</span>::<span class="n">default</span><span class="p">();</span><span class="w"></span>
<span class="k">for</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="mi">0</span><span class="o">..</span><span class="mi">4</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">d</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">a</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="w"> </span><span class="o">&gt;</span><span class="w"> </span><span class="mf">0.0</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">b</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">c</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="w"> </span><span class="p">};</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="212517362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517362">(Oct 07 2020 at 05:44)</a>:</h4>
<p>it should be possible, i agree, but not something we want to have easily happen on accident, which i feel could happen</p>



<a name="212517385"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517385" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517385">(Oct 07 2020 at 05:45)</a>:</h4>
<p>hence why I like:<br>
<span class="user-mention silent" data-user-id="229517">Jacob Lifshay</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20movemasquerade/near/212517150">said</a>:</p>
<blockquote>
<p>we could also just define <code>m8x16</code> to be either <code>&lt;16 x i1&gt;</code> or <code>&lt;16 x i8&gt;</code> depending on the architecture and define a <code>fullmask8x16</code> when the user explicitly wants <code>&lt;16 x i8&gt;</code></p>
</blockquote>



<a name="212517474"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517474" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517474">(Oct 07 2020 at 05:47)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> <a href="https://gcc.godbolt.org/z/xE1WWW">https://gcc.godbolt.org/z/xE1WWW</a></p>



<a name="212517532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517532">(Oct 07 2020 at 05:49)</a>:</h4>
<p>cool.</p>



<a name="212517535"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517535" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517535">(Oct 07 2020 at 05:49)</a>:</h4>
<p>e.g. it's even worse on neon — note that f_sse_inlined does the same as f_sse and cmp_f.</p>



<a name="212517536"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517536" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517536">(Oct 07 2020 at 05:49)</a>:</h4>
<p>I was wondering if godbolt could be persuaded to generate ARM code.</p>



<a name="212517606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517606">(Oct 07 2020 at 05:51)</a>:</h4>
<p>it can but you probably will have to do stuff like pass in --help and --version as args inside the godbolt window to figure out how. also the attributes <a href="https://github.com/rust-lang/rust/issues/1">#1</a> thing needs modifying for each arch (e.g. llvm ir continues to be non-portable)</p>



<a name="212517674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517674">(Oct 07 2020 at 05:52)</a>:</h4>
<p>hey i can almost read aarch64! (normally i use armv4t code, gba and all that)</p>



<a name="212517677"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517677" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517677">(Oct 07 2020 at 05:53)</a>:</h4>
<p>lol</p>



<a name="212517681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517681">(Oct 07 2020 at 05:53)</a>:</h4>
<p>i mean, no vectors there so.</p>



<a name="212517686"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517686" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517686">(Oct 07 2020 at 05:53)</a>:</h4>
<p>go team Raspi</p>



<a name="212517745"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517745" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517745">(Oct 07 2020 at 05:54)</a>:</h4>
<p>i actually posted most of this thread from a raspi4 (though now i'm on the laptop)</p>



<a name="212517748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517748">(Oct 07 2020 at 05:54)</a>:</h4>
<p>anyway this is very convincing to me that it's worth it to have e.g. <code>m32x8</code> and <code>m16x8</code> be just different types. using a mask here already helps defend us from guaranteeing the specific binary values (unlike if we had comparisons return <code>u32x8</code> and such).</p>



<a name="212517749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517749">(Oct 07 2020 at 05:54)</a>:</h4>
<p>nice.</p>



<a name="212517771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517771">(Oct 07 2020 at 05:55)</a>:</h4>
<p>although i think the name "mask" does stronly imply a... specific binary representaion</p>



<a name="212517773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517773">(Oct 07 2020 at 05:55)</a>:</h4>
<p>that's true, I do not want to guarantee binary values because some arch is gonna be a joker</p>



<a name="212517836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517836">(Oct 07 2020 at 05:56)</a>:</h4>
<p>it seems unlikely that producing a mask from a comparison won't be cheap on any hypothetical arch, since that's such a common thing</p>



<a name="212517841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517841">(Oct 07 2020 at 05:56)</a>:</h4>
<p>and say a mask for u8x16 or w/e is not [Bits[M; 8]; 8]</p>



<a name="212517856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517856">(Oct 07 2020 at 05:56)</a>:</h4>
<p>but actually [Bits[0,0,0,0,0,0,0,M]; 8]</p>



<a name="212517876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517876">(Oct 07 2020 at 05:57)</a>:</h4>
<p>that's still very cheap to convert. waaaaaaaaaaaaaaaaaaaaay cheaper than that mess i linked with the i1 vec</p>



<a name="212517929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517929">(Oct 07 2020 at 05:58)</a>:</h4>
<p>(its cheap to convert because converting it is equivalent to a signed int negate)</p>



<a name="212517933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517933">(Oct 07 2020 at 05:58)</a>:</h4>
<p>oh yes.</p>



<a name="212517956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212517956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212517956">(Oct 07 2020 at 05:59)</a>:</h4>
<p>but also <a href="https://github.com/riscv/riscv-v-spec/blob/master/v-spec.adoc#sec-mask-register-layout">https://github.com/riscv/riscv-v-spec/blob/master/v-spec.adoc#sec-mask-register-layout</a></p>



<a name="212518032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212518032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212518032">(Oct 07 2020 at 06:00)</a>:</h4>
<p>so it's compares more or less automatically have a builtin movemask</p>



<a name="212518102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212518102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212518102">(Oct 07 2020 at 06:02)</a>:</h4>
<p>ah, you can use the mask register to expand cheaply by directly using its mask for a bit negate on 0</p>



<a name="212518106"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212518106" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212518106">(Oct 07 2020 at 06:02)</a>:</h4>
<p>if i'm reading right that would work</p>



<a name="212518109"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212518109" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212518109">(Oct 07 2020 at 06:02)</a>:</h4>
<p>ish, it goes into a vector register.</p>



<a name="212518110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212518110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212518110">(Oct 07 2020 at 06:03)</a>:</h4>
<p>yeah.</p>



<a name="212518142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212518142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212518142">(Oct 07 2020 at 06:03)</a>:</h4>
<p>And "it goes into a vector register" means it isn't just a scalar value!</p>



<a name="212518190"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212518190" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212518190">(Oct 07 2020 at 06:04)</a>:</h4>
<p>that seems fine so long as you can just use it as a mask for another instruction directly</p>



<a name="212518196"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212518196" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212518196">(Oct 07 2020 at 06:04)</a>:</h4>
<p>yes, it's actually quite peculiar to RISCV-V how mask works.</p>



<a name="212518199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212518199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212518199">(Oct 07 2020 at 06:04)</a>:</h4>
<p>honestly riscv's option seems like the most flexible, and could cheaply emulate any of the things we choose</p>



<a name="212518215"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212518215" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212518215">(Oct 07 2020 at 06:05)</a>:</h4>
<p><a href="https://github.com/riscv/riscv-v-spec/blob/master/v-spec.adoc#vector-masking">https://github.com/riscv/riscv-v-spec/blob/master/v-spec.adoc#vector-masking</a></p>



<a name="212518219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212518219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212518219">(Oct 07 2020 at 06:05)</a>:</h4>
<p>yeah i saw that</p>



<a name="212518220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212518220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212518220">(Oct 07 2020 at 06:05)</a>:</h4>
<p>nod.</p>



<a name="212518380"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212518380" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212518380">(Oct 07 2020 at 06:08)</a>:</h4>
<p>doing it like that would slightly pessimize riscv for cases where everything isn't inlined (since you can't just directly use that mask elsewhere), but it seems like it would not be nearly as devastating as the alternative on x86/arm/honestly probably everywhere else</p>



<a name="212518672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212518672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212518672">(Oct 07 2020 at 06:14)</a>:</h4>
<p>honestly for masking risv's approach is clearly the best (very clean and almost any conversion of the data is extremely cheap)... (but i still think working with non-statically sized vectors sounds awful lol)</p>



<a name="212519417"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212519417" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212519417">(Oct 07 2020 at 06:29)</a>:</h4>
<p>anyway i think the real downside of the current mask design is not because it's likely some future arch will come up with a new way of doing things that is hard to convert to it. the issue is clearly that it's a shitload of types:</p>
<ul>
<li>"scalar" mask values (basially a <code>OnlyZeroOrMax$Int</code> type. IMO these should probably not be exposed) <code>mask8</code>, <code>mask16</code>, <code>mask32</code>, <code>mask64</code>, <code>mask128</code>, <code>masksize</code> .</li>
<li>many vector mask values: <code>mask8x8</code>, <code>mask8x16</code>, <code>mask8x32</code>, <code>mask8x64</code>, <code>mask16x4</code>, <code>mask16x8</code>, <code>mask16x16</code>, <code>mask16x32</code>, <code>mask32x2</code>, <code>mask32x4</code>, <code>mask32x8</code>, <code>mask32x16</code>, <code>mask64x2</code>, <code>mask64x4</code>, <code>mask64x8</code>, <code>mask128x4</code>, <code>mask128x2</code>, <code>masksizex2</code>, <code>masksizex4</code>, <code>masksizex8</code></li>
</ul>



<a name="212519442"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212519442" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212519442">(Oct 07 2020 at 06:29)</a>:</h4>
<p>uh whats the timeline on min_const_generics again?</p>



<a name="212519519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212519519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212519519">(Oct 07 2020 at 06:30)</a>:</h4>
<p>"by the end of the year"</p>



<a name="212519531"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212519531" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212519531">(Oct 07 2020 at 06:31)</a>:</h4>
<p>something's going to be stabilized-ish in 2020, smaller features will be stabilized in 2021 (so, we can count on them being even stronger, though in an ill-defined way, by the time we stabilize anything)</p>



<a name="212519545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212519545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212519545">(Oct 07 2020 at 06:31)</a>:</h4>
<p>some of the work currently happening is literally just hacking the const generic feature into a million smaller features.</p>



<a name="212519603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212519603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212519603">(Oct 07 2020 at 06:32)</a>:</h4>
<p>is there a way we can leverage it for the sizes of vectors?</p>



<a name="212519624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212519624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212519624">(Oct 07 2020 at 06:32)</a>:</h4>
<p>I do believe so, in fact, but we will have to sit down and talk to them and maybe help them a bit with hacking the compiler.</p>



<a name="212519649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212519649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212519649">(Oct 07 2020 at 06:33)</a>:</h4>
<p>re: packing masks into an explicit uint, what are the reasons to not target usize exactly?</p>



<a name="212519663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212519663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212519663">(Oct 07 2020 at 06:33)</a>:</h4>
<p>can you elaborate?</p>



<a name="212519667"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212519667" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212519667">(Oct 07 2020 at 06:33)</a>:</h4>
<p>uhm, that was raised a while back.</p>



<a name="212519717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212519717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212519717">(Oct 07 2020 at 06:34)</a>:</h4>
<p>"should it be a u32 or u64?"<br>
"why not usize, exactly?"</p>



<a name="212519720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212519720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212519720">(Oct 07 2020 at 06:34)</a>:</h4>
<p>do you mean my example where i had <code>mask32x4</code> return u8? that would be fine to have it return <code>usize</code> instead</p>



<a name="212519737"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212519737" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212519737">(Oct 07 2020 at 06:34)</a>:</h4>
<p>eh, just as a generic question sortof!</p>



<a name="212519764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212519764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212519764">(Oct 07 2020 at 06:35)</a>:</h4>
<p>I guess "because it is hypothetically possible to have a 32-bit platform with 512-bit vectors"</p>



<a name="212519844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212519844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212519844">(Oct 07 2020 at 06:36)</a>:</h4>
<p>or a 64-bit platform with 1024-bit vectors that supports u8s</p>



<a name="212519858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212519858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212519858">(Oct 07 2020 at 06:36)</a>:</h4>
<p>yes, <code>mask8x64</code> (for 512bit SIMD) needs to pack into u64 and cant use usize. but i think the mask vector types don't really need to agree on the packed type, it can just be an inherent method and not a trait. that avoids issues if someone adds 1024-bit vectors in the future</p>



<a name="212519862"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212519862" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212519862">(Oct 07 2020 at 06:36)</a>:</h4>
<p>right.</p>



<a name="212519900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212519900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212519900">(Oct 07 2020 at 06:37)</a>:</h4>
<p>(in case it's unclear at all, the <code>mask8</code>, <code>mask16</code>, <code>mask32</code>, <code>mask64</code>, <code>mask128</code>, and <code>masksize</code> are the lanes of the mask vec, and not the bitpacked mask)</p>



<a name="212519987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212519987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212519987">(Oct 07 2020 at 06:39)</a>:</h4>
<p>so i think the desire to const generics impacts every part of the API and not just masking, and it doesnt really impact masking in a different way than it impacts other stuff</p>



<a name="212520171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212520171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212520171">(Oct 07 2020 at 06:43)</a>:</h4>
<p>assuming we remove or at least dont publically expose the maskvec lane types we then have 20 mask vector types, which is the same number of vector types that we have for {signed,unsigned} ints (seprately, e.g. 20 signed vec types and 20 unsigned vec types).</p>



<a name="212520253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212520253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212520253">(Oct 07 2020 at 06:44)</a>:</h4>
<p>const generics would make that 6 each which probably doesn't super meaningfully change the nature of the API, just the size of it.</p>



<a name="212520853"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212520853" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212520853">(Oct 07 2020 at 06:57)</a>:</h4>
<p>If you mean we could genericize over lane widths? yeah, 2, 4, 8, 16, 32, 64</p>



<a name="212520910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212520910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212520910">(Oct 07 2020 at 06:58)</a>:</h4>
<p>yeah, but i kinda suspect repr(simd) might get mad about weird sizes</p>



<a name="212520933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212520933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212520933">(Oct 07 2020 at 06:59)</a>:</h4>
<p>and i think min const generics dont let you limit things like that? maybe?</p>



<a name="212520969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212520969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212520969">(Oct 07 2020 at 06:59)</a>:</h4>
<p>in practice most of the power of our API will be locked behind <a href="https://github.com/rust-lang/compiler-team/issues/340">https://github.com/rust-lang/compiler-team/issues/340</a></p>



<a name="212521173"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212521173" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212521173">(Oct 07 2020 at 07:02)</a>:</h4>
<p>i think with current design direction, in the future we'd probably still be able to do <code>pub type f32x4 = SimdF32&lt;4&gt;</code> or even <code>pub type f32x4 = Simd&lt;f32, 4&gt;;</code>, and i vaguely remember that waiting for const generics is part of why packed_simd stalled</p>



<a name="212521193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212521193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212521193">(Oct 07 2020 at 07:03)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Do.20the.20const.20SIMD-shuffle.3F/near/207927943">said</a>:</p>
<blockquote>
<p>you can then write <code>fn simd_stuff&lt;const N: usize&gt;() where [u8;  BOUND - N]</code> which fails to compile if <code>N</code> is greater than <code>BOUND</code></p>
<p>I personally expect us to still be able to add these bounds to methods we want to stabilize even if they can only be satisfied by using concrete values. That would forbid users on stable from writing <code>simd_stuff::&lt;CONST_PARAM&gt;</code> at the start</p>
</blockquote>



<a name="212521266"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212521266" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212521266">(Oct 07 2020 at 07:04)</a>:</h4>
<p>also having it not be generic might help push people towards chosing a realistic size for their architecture. maybe. (i can dream)</p>



<a name="212521291"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212521291" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212521291">(Oct 07 2020 at 07:04)</a>:</h4>
<p>...why would they introduce arch-specific concerns when writing arch-generic code?</p>



<a name="212521317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212521317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212521317">(Oct 07 2020 at 07:05)</a>:</h4>
<p>i mean, they're gonna have a bad time if they use SimdVec&lt;u8, 13&gt;</p>



<a name="212521337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212521337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212521337">(Oct 07 2020 at 07:05)</a>:</h4>
<p>const wf lets us ban non-n^2 length vectors</p>



<a name="212521439"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212521439" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212521439">(Oct 07 2020 at 07:07)</a>:</h4>
<p>okay, they still should probably pick 128bit (or sometimes 256) if they care about perf, and imo if you don't care about perf you're prob better served by just writing the obvious scalar code</p>



<a name="212521541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212521541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212521541">(Oct 07 2020 at 07:09)</a>:</h4>
<p>yeah <code>packed_simd</code> did the const generics thing. It.. makes the api harder to understand. We've got our initial charter as being against the idea of repeating that path.</p>



<a name="212521592"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212521592" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212521592">(Oct 07 2020 at 07:10)</a>:</h4>
<p>It's not impossible to change that but.. we'd need a pretty sturdy justification i think.</p>



<a name="212521609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212521609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212521609">(Oct 07 2020 at 07:10)</a>:</h4>
<p>sold</p>



<a name="212521614"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212521614" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212521614">(Oct 07 2020 at 07:10)</a>:</h4>
<p>We don't want to make everything const generic but there will be cases where we do intend to use it.<br>
And with all due respect, there are reasons to explicitly communicate that an algorithm is vectorizable in a way that opens the door for significant performance gains without needing to worry about the specific architecture size.</p>



<a name="212521668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212521668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212521668">(Oct 07 2020 at 07:11)</a>:</h4>
<p>LLVM can fail to vectorize "obvious" vectors. Implicit vectorization is not a programming model. "This is mostly vectorizable if the architecture supports it" is a valid thing to want to communicate.</p>



<a name="212521731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212521731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212521731">(Oct 07 2020 at 07:12)</a>:</h4>
<p>yeah that's plausible, i also think there are cases where it's reasonable to reach for a simd type even if it's not actively hot code (probably is convenient for mathy stuff). that said i'd consider code where you're worrying about if llvm is vectorizing stuff to be code where you care about the perf</p>



<a name="212521763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212521763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212521763">(Oct 07 2020 at 07:13)</a>:</h4>
<p>Mostly I think, const generics helps save on code writing time in some cases, but we've got sufficiently few cases and we've got macro_rules! so i think we can already generate the specific cases we want to handle quickly enough.</p>



<a name="212521766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212521766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212521766">(Oct 07 2020 at 07:13)</a>:</h4>
<p>Intel CPUs can literally execute 512 bit vector instructions as 128 bit vectors until AVX512 turns on. :^)</p>



<a name="212521791"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212521791" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212521791">(Oct 07 2020 at 07:13)</a>:</h4>
<p>4k vectors :3</p>



<a name="212521837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212521837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212521837">(Oct 07 2020 at 07:14)</a>:</h4>
<p>noticing "this is vectorizable at a performance gain of at least x5, I should probably use <code>core::simd</code>" is not the same as caring about every last % of performance</p>



<a name="212521843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212521843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212521843">(Oct 07 2020 at 07:14)</a>:</h4>
<p>i mean, there's real non-obvious performance cost to the wider vectors. anyway this is not a hill i want to die on, people can use the api however they want</p>



<a name="212521872"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212521872" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212521872">(Oct 07 2020 at 07:14)</a>:</h4>
<p>The dilemma is in fact that people will use the API however they want and not how we imagine they will, yes.</p>



<a name="212521897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212521897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212521897">(Oct 07 2020 at 07:15)</a>:</h4>
<p>I guess the thing to remember is that people can always use a thing wrong, we just need to make it easy enough to use right and provide help when they shout on reddit</p>



<a name="212522036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212522036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212522036">(Oct 07 2020 at 07:17)</a>:</h4>
<p>and e.g. someone is almost certainly to implement a language against our API and then we <strong>really</strong> won't know how the API is being used because it's being used by proxy by users who may not even be aware they're using it. :^)</p>



<a name="212522352"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212522352" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212522352">(Oct 07 2020 at 07:22)</a>:</h4>
<p>i mean i do genuinely think scalar code is easier to read than vector code 9 times out of 10, and that most people should reach for 128bit vectors if they don't specifically know better, but these are mostly personal opinions and certainly not things i want to encode in the API. (i was mostly thinking/worried about users using SimdVec&lt;T, N&gt; for strange Ns, when they really want [T; N]. but i didn't realize that we had the ability to limit the values N can take. anyway,  if const generics are out this isn't a concern really)</p>



<a name="212522416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212522416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212522416">(Oct 07 2020 at 07:23)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281757">Jubilee</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20movemasquerade/near/212521337">said</a>:</p>
<blockquote>
<p>const wf lets us ban non-n^2 length vectors</p>
</blockquote>
<p>I think we should plan on vector lengths not being required to be a power of 2, maybe not right away, but at least when RISC-V V and/or SimpleV support is added, since RISC-V V supports arbitrary vector lengths by setting the Vector Length register to whatever length you want. SimpleV additionally supports using e.g. 7 consecutive 64-bit registers to store a <code>f32x14</code> or 13 registers to store a <code>i8x49</code> where the last register has some unused bytes.</p>



<a name="212522655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212522655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212522655">(Oct 07 2020 at 07:26)</a>:</h4>
<p>That sounds... less portable though</p>



<a name="212522669"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212522669" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212522669">(Oct 07 2020 at 07:26)</a>:</h4>
<p>that value changes at runtime though no? or is the idea that you'd set compile code that uses f32x14, but first sets the register to a value that lets that run well</p>



<a name="212522726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212522726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212522726">(Oct 07 2020 at 07:27)</a>:</h4>
<p>erm... </p>
<p>the bits in a RISCV-V vector register must be 2^n though, no?</p>



<a name="212522899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212522899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212522899">(Oct 07 2020 at 07:30)</a>:</h4>
<p>anyway i find the combination of it not working out amazingly for packed_simd, and "We've got our initial charter as being against the idea of repeating that path." fairly compelling. someone in the future can always rfc replacing the current types with type aliases anyway.</p>



<a name="212522936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212522936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212522936">(Oct 07 2020 at 07:30)</a>:</h4>
<p>sounds like: physically a single register is "2^n bits", but you can combo registers and also ignore some of the bytes, so overall it's just "8*n bits" because you can put the byte bound anywhere you want</p>



<a name="212523049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212523049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212523049">(Oct 07 2020 at 07:31)</a>:</h4>
<p><span class="user-mention silent" data-user-id="209168">Thom Chiovoloni</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20movemasquerade/near/212522669">said</a>:</p>
<blockquote>
<p>that value changes at runtime though no? or is the idea that you'd set compile code that uses f32x14, but first sets the register to a value that lets that run well</p>
</blockquote>
<p>RISC-V V is mostly designed for the case where the value changes at runtime, every CPU has a different hardware limit on vector length.<br>
SimpleV is designed to work well with both fixed-length and variable vectors, every CPU is required to support lengths up to 64. Lengths greater than 64 won't work due to predicate masks being just a u64 in an integer register.</p>



<a name="212523083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212523083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212523083">(Oct 07 2020 at 07:31)</a>:</h4>
<p>64 bytes?</p>



<a name="212523281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212523281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212523281">(Oct 07 2020 at 07:33)</a>:</h4>
<p>i mean we cover powers of two up to 64 bytes.</p>



<a name="212523420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212523420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212523420">(Oct 07 2020 at 07:35)</a>:</h4>
<p><span class="user-mention silent" data-user-id="224471">Lokathor</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20movemasquerade/near/212522936">said</a>:</p>
<blockquote>
<p>sounds like: physically a single register is "2^n bits", but you can combo registers and also ignore some of the bytes, so overall it's just "8*n bits" because you can put the byte bound anywhere you want</p>
</blockquote>
<p>That's how SimpleV works. all registers are 64 bits, vectors are where the bytes that make up consecutive registers are reinterpreted as <code>f32x13</code> or whatever.</p>



<a name="212523645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212523645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212523645">(Oct 07 2020 at 07:38)</a>:</h4>
<p>i think we should worry about that after doing fixed power of 2 sizes, since it's not like they're disasterous anywhere</p>



<a name="212523819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212523819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212523819">(Oct 07 2020 at 07:40)</a>:</h4>
<p><span class="user-mention silent" data-user-id="209168">Thom Chiovoloni</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20movemasquerade/near/212523083">said</a>:</p>
<blockquote>
<p>64 bytes?</p>
</blockquote>
<p>64 lanes in a vector since you need 1 predicate bit per lane. you can have up to <code>&lt;64 x u64&gt;</code> or, using the subvectors functionality, up to 128 underlying 64 bit registers since there are only 128 registers for fp and 128 for integers.</p>



<a name="212523910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212523910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212523910">(Oct 07 2020 at 07:41)</a>:</h4>
<p>back to the masks, if we find having 20 mask types problematic, we might be able to get away with just making them a wrapper like <code>Mask&lt;u32x4&gt;</code> instead of <code>mask32x4</code>.  I don't actually know that this would be worth while, but it's an option i just thought of</p>



<a name="212523997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212523997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212523997">(Oct 07 2020 at 07:42)</a>:</h4>
<p><span class="user-mention silent" data-user-id="209168">Thom Chiovoloni</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20movemasquerade/near/212523645">said</a>:</p>
<blockquote>
<p>i think we should worry about that after doing fixed power of 2 sizes, since it's not like they're disasterous anywhere</p>
</blockquote>
<p>sounds good, as long as we're not guaranteeing that we'll only ever provide powers of 2 lengths.</p>



<a name="212524143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212524143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212524143">(Oct 07 2020 at 07:44)</a>:</h4>
<p>re: <code>Mask&lt;uNxK&gt;</code> actually it's probably fine to keep it as is for now, making it a wrapper sounds annoying (probably requires specialization, or at least some heavy weight trait shenanigans.</p>



<a name="212524161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212524161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212524161">(Oct 07 2020 at 07:44)</a>:</h4>
<p><span class="user-mention silent" data-user-id="209168">Thom Chiovoloni</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20movemasquerade/near/212523910">said</a>:</p>
<blockquote>
<p>back to the masks, if we find having 20 mask types problematic, we might be able to get away with just making them a wrapper like <code>Mask&lt;u32x4&gt;</code> instead of <code>mask32x4</code>.  I don't actually know that this would be worth while, but it's an option i just thought of</p>
</blockquote>
<p>I think that would be unnecessarily messy, since <code>Mask&lt;u32x4&gt;</code>, <code>Mask&lt;i32x4&gt;</code>, and <code>Mask&lt;f32x4&gt;</code> would all be different types, right?</p>



<a name="212524207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212524207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212524207">(Oct 07 2020 at 07:45)</a>:</h4>
<p>i was thinking it would always be a unsigned int type but honestly it's a half-baked thought that only reduces the number of types in the API and not the complexity</p>



<a name="212524330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212524330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212524330">(Oct 07 2020 at 07:47)</a>:</h4>
<p>and honestly the only reason i care at all is that i think we'll be the part of stdlib that defines by far more types than any other, which isn't ideal</p>



<a name="212524348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212524348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212524348">(Oct 07 2020 at 07:47)</a>:</h4>
<p>Hm, no.<br>
LMUL has only 2^N values.<br>
SEW has only 2^N values.<br>
VLEN and ELEN are also 2^N values.<br>
How do you specify a non-2^N vector length in RISCV-V?</p>



<a name="212524374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212524374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212524374">(Oct 07 2020 at 07:47)</a>:</h4>
<p>setting VL to a non-power-of-2</p>



<a name="212524441"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212524441" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212524441">(Oct 07 2020 at 07:48)</a>:</h4>
<p>what happens if that register changes while you have vectors out</p>



<a name="212524460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212524460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212524460">(Oct 07 2020 at 07:48)</a>:</h4>
<p>you aren't allowed</p>



<a name="212524505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212524505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212524505">(Oct 07 2020 at 07:49)</a>:</h4>
<blockquote>
<p>Thread contexts with active vector state cannot be migrated during execution between harts that have any difference in VLEN or ELEN parameters.</p>
</blockquote>



<a name="212524530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212524530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212524530">(Oct 07 2020 at 07:49)</a>:</h4>
<p>same kinda thing as if you set the stack pointer to a different value, the compiler keeps track of it and if you change it behind it's back you get UB.</p>



<a name="212524657"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212524657" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212524657">(Oct 07 2020 at 07:51)</a>:</h4>
<p>IIRC you can totally change VL without needing to reset the vector state. the stuff past VL just becomes unused.</p>



<a name="212524671"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212524671" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212524671">(Oct 07 2020 at 07:51)</a>:</h4>
<p>right that kinda thing is along the lines of "you can assume well-behaved rust code will never touch this register unless it's doign some very hairy platform-specific code" which may not be something the portable simd api needs to worry about</p>



<a name="212524777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212524777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212524777">(Oct 07 2020 at 07:52)</a>:</h4>
<p>well behaved rust code totally changes the stack pointer all the time ... when the compiler expects it to. same thing with VL.</p>



<a name="212524810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212524810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212524810">(Oct 07 2020 at 07:53)</a>:</h4>
<p>so the compiler would track this?</p>



<a name="212524821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212524821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212524821">(Oct 07 2020 at 07:53)</a>:</h4>
<p>yup</p>



<a name="212524833"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212524833" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212524833">(Oct 07 2020 at 07:53)</a>:</h4>
<p>i mean, llvm has a bad track record for tracking control register values</p>



<a name="212524903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212524903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212524903">(Oct 07 2020 at 07:54)</a>:</h4>
<p>depends on the register.</p>



<a name="212524970"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212524970" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212524970">(Oct 07 2020 at 07:55)</a>:</h4>
<p>anyway, i feel like this is super in the weeds.</p>



<a name="212525011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212525011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212525011">(Oct 07 2020 at 07:55)</a>:</h4>
<p>some work great, such as the stack pointer or x86 zero flag. others, not so much.</p>



<a name="212525833"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212525833" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212525833">(Oct 07 2020 at 08:05)</a>:</h4>
<p>this feels somewhat equivalent to the fpenv since it's also supposed to use this knowledge for codegen.</p>
<p>anyway. tldr seems to be: the current mask design is probably mostly fine.</p>
<ul>
<li>
<p>trying to unify masks of the same lane count (as some fully opaque bool or mask vector) isn't viable since llvm does a very bad job here unless it can inline everything. it also seems every current arch we can find either produces these kinds of mask from a comparisons, or turn a comparison result into a mask in 1 or 2 cheap instructions.</p>
</li>
<li>
<p>also, since it's in the title movemask isn't important enough to warrant anything beyond an inherent method the mask types, and it's probably not worth explicitly representing 1-bit mask vectors expect as integers.</p>
</li>
</ul>
<p>that said this sounds suspiciously like the set of things i felt going in, so perhaps i'm projecting.</p>



<a name="212526932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212526932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212526932">(Oct 07 2020 at 08:18)</a>:</h4>
<p>GPU languages seem to use mostly uints in their lane masking code.</p>



<a name="212563657"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212563657" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212563657">(Oct 07 2020 at 14:10)</a>:</h4>
<p>Went to bed so just catching up--i agree that movemask itself it's necessarily important that but AVX512 still has an enormous packed mask API</p>



<a name="212563952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212563952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212563952">(Oct 07 2020 at 14:12)</a>:</h4>
<p>I would like to at least experiment with packed masks (and see if it codegens as expected), unless it seems like a waste of time I can submit a PR so we can get a feeling of what our API might look like</p>



<a name="212564051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212564051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212564051">(Oct 07 2020 at 14:13)</a>:</h4>
<p>Worst case we scrap the PR and start from what we've learned</p>



<a name="212564423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212564423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212564423">(Oct 07 2020 at 14:16)</a>:</h4>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> by packed mask you mean one-bit-per-lane? either way the AVX512 mask API seems pretty different than the other mask stuff, so IDK if it needs to be handled the same.</p>



<a name="212564493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212564493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212564493">(Oct 07 2020 at 14:16)</a>:</h4>
<p>i mean it's a different kind of api and if it also uses a different mask layout then... that says to me it probably shouldn't be the same</p>



<a name="212564722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212564722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212564722">(Oct 07 2020 at 14:18)</a>:</h4>
<p>Yeah, 1 bit per lane.  Actually, a huge amount of SSE and AVX APIs were ported to using the 1-bit masks in AVX512 so the APIs can be nearly identical</p>



<a name="212564810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212564810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212564810">(Oct 07 2020 at 14:18)</a>:</h4>
<p>ugh</p>



<a name="212564825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212564825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212564825">(Oct 07 2020 at 14:19)</a>:</h4>
<p>And my understanding is as long as the type is repr(simd) it should work</p>



<a name="212564934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212564934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212564934">(Oct 07 2020 at 14:19)</a>:</h4>
<p>At least as far as function calls are concerned</p>



<a name="212564941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212564941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212564941">(Oct 07 2020 at 14:19)</a>:</h4>
<p>i'm not 100% sure i follow, would this be only for 1-bit masks?</p>



<a name="212565040"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212565040" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212565040">(Oct 07 2020 at 14:20)</a>:</h4>
<p>Would what be?</p>



<a name="212565313"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212565313" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212565313">(Oct 07 2020 at 14:22)</a>:</h4>
<p>I'm suggesting for now providing both types of masks (with conversions between the two) and some subset of operations that utilize them</p>



<a name="212565451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212565451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212565451">(Oct 07 2020 at 14:23)</a>:</h4>
<p>And at least with a PR we have something tangible to critique</p>



<a name="212565964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212565964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212565964">(Oct 07 2020 at 14:26)</a>:</h4>
<p>I mean my main issue here is that it's only going to be efficient on avx512 and will double the API surface for the mask code, and make it confusing for users to decide what to use.</p>



<a name="212566162"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212566162" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212566162">(Oct 07 2020 at 14:28)</a>:</h4>
<p>It sounds to me that there is an efficient (for some ops) implementation that uses movemask, and for some architectures such as RISC-V the wide masks are inefficient and the narrow masks should be preferred</p>



<a name="212566290"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212566290" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212566290">(Oct 07 2020 at 14:29)</a>:</h4>
<p>yeah riscv has support for that too. the issue sin't the movemask so much as that the fallback code has to undo a movemask to implement any masking operation... which is not efficient</p>



<a name="212566407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212566407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212566407">(Oct 07 2020 at 14:30)</a>:</h4>
<p>I also think it's shortsighted to discount AVX512 when in a few years it will probably be the dominant vector instruction set. If anything this indicates to me that the narrow masks may be more heavily adopted as time goes on</p>



<a name="212566613"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212566613" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212566613">(Oct 07 2020 at 14:31)</a>:</h4>
<p>you think it will/ i've really seen no indication that avx512 is going to come to consumer machines.</p>



<a name="212566789"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212566789" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212566789">(Oct 07 2020 at 14:32)</a>:</h4>
<p>It's already available on some consumer CPUs</p>



<a name="212567058"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212567058" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212567058">(Oct 07 2020 at 14:34)</a>:</h4>
<p>I've used either a skylake or cannon lake i5 that supports it, as well as a mac pro with I believe an i9 that supports it</p>



<a name="212567072"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212567072" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212567072">(Oct 07 2020 at 14:34)</a>:</h4>
<p>I know, but are there plans for that to increase? i also think you're overestimating how long it takes for new instructions to be something people actually want to use</p>
<p>that said, the biggest reason i'm discounting it is also that it doesn't seem to offer a meaningful improvement to the API, just largely another version of it</p>



<a name="212567118"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212567118" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212567118">(Oct 07 2020 at 14:35)</a>:</h4>
<p>i9 macs don't support it unless that's changed very recently</p>



<a name="212567150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212567150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212567150">(Oct 07 2020 at 14:35)</a>:</h4>
<p>Maybe it's xeon then</p>



<a name="212567319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212567319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212567319">(Oct 07 2020 at 14:36)</a>:</h4>
<p>i also think that rather than add new types for 1 bit masks you can probably just use unsigned integers (or int vectors? not sure the api shape).</p>



<a name="212567374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212567374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212567374">(Oct 07 2020 at 14:37)</a>:</h4>
<p>Yeah that was what I was imagining. The narrow masks likely have a different API</p>



<a name="212567656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212567656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212567656">(Oct 07 2020 at 14:39)</a>:</h4>
<p>I agree that it's a significant addition to the API but I'm worried that not supporting it rules out AVX512 and RISC-V (admittedly not the most common use cases, for now at least)</p>



<a name="212568057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212568057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212568057">(Oct 07 2020 at 14:42)</a>:</h4>
<p>it's a significant addition and it feels <em>very</em> much like the kind of API where someone unfamiliar with simd code would assume it's the main/correct way for dealing with what's conceptually bool vector, and the downside of "operations are O(lanes) unless you have a very high target_feature configured or are targetting riscv" just feels like a huge footgun</p>



<a name="212568263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212568263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212568263">(Oct 07 2020 at 14:44)</a>:</h4>
<p>and for riscv vectors AFAICT it's still very efficient to turn the bit masks to/from the wider mask vectors that are much more common</p>



<a name="212568454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212568454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212568454">(Oct 07 2020 at 14:45)</a>:</h4>
<p>is that true for the avx512 bit masks? e.g. can they "undo" a movemask efficiently?</p>



<a name="212568865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212568865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212568865">(Oct 07 2020 at 14:47)</a>:</h4>
<p>Honestly not sure, but I don't think the normal usage would be to do that.</p>



<a name="212569072"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212569072" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212569072">(Oct 07 2020 at 14:48)</a>:</h4>
<p>I just checked, say you are only using 128 bit vectors. With AVX a blendv has double the latency and half the throughput of an AVX512 masked blend on the same vector</p>



<a name="212569240"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212569240" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212569240">(Oct 07 2020 at 14:49)</a>:</h4>
<p>There really does seem to be a significant performance benefit of using them when they are available. I agree it's possible to accidentally use the wrong type of mask, but it's already possible to generate suboptimal code if you're not somewhat aware of what you're doing</p>



<a name="212569840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212569840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212569840">(Oct 07 2020 at 14:53)</a>:</h4>
<p>I also imagine in many cases the compiler will be smart enough to optimize the narrow masks to wide masks when they remain in register, since that's LLVM's representation in the first place</p>



<a name="212569966"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212569966" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212569966">(Oct 07 2020 at 14:53)</a>:</h4>
<p>right no, but if they can cheaply go back and forth, IMO they should just use the same api as everything else rather than add a duplicate version of the API that runs more slowly for most targets.</p>
<p>this way, for people on AVX512: in the case that stuff's inlined, it's very that LLVM will be able to "see through" something cheap like that, and in the case that stuff is <em>not</em> inlined, you have an extra few instructions of overhead. I strongly doubt it can do this for the operation of manually undoing a movemask — and especially not in the case where it's tied to the algo at all</p>



<a name="212569973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212569973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212569973">(Oct 07 2020 at 14:54)</a>:</h4>
<p>Wide masks to narrow masks I'm not so sure, since they are normal vector registers and support more operations</p>



<a name="212570161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212570161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212570161">(Oct 07 2020 at 14:55)</a>:</h4>
<p>wide to narrow is easier than narrow to wide i think. i think wide to narrow is O(log(lanes)) and narrow to wide is O(lanes) for most ISAs</p>



<a name="212570307"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212570307" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212570307">(Oct 07 2020 at 14:56)</a>:</h4>
<p>I meant that it's harder to verify that you didn't do something to a wide mask to make it no longer a mask.  Narrow masks don't have that problem</p>



<a name="212570330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212570330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212570330">(Oct 07 2020 at 14:56)</a>:</h4>
<p>also it's worth noting that LLVM does abysmally for &lt;bool x N&gt; which seems strictly easier to me than the &lt;bit x N&gt; case</p>



<a name="212570416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212570416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212570416">(Oct 07 2020 at 14:57)</a>:</h4>
<p>Isn't that because bool is specifically defined as 8 bits but utilizing only the LSB? i1 is not defined that way</p>



<a name="212570417"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212570417" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212570417">(Oct 07 2020 at 14:57)</a>:</h4>
<p>yeah, but you aren't really relying on the compiler to know that. it's encoded in the type system (hence the mask vecs being their own types and no unsigned int vecs)</p>



<a name="212570475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212570475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212570475">(Oct 07 2020 at 14:57)</a>:</h4>
<p>the code i'm referring to was i1.</p>



<a name="212570611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212570611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212570611">(Oct 07 2020 at 14:58)</a>:</h4>
<p>Do you have it on godbolt?</p>



<a name="212570641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212570641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212570641">(Oct 07 2020 at 14:58)</a>:</h4>
<p><a href="https://gcc.godbolt.org/z/7xoxab">https://gcc.godbolt.org/z/7xoxab</a> / <a href="https://gcc.godbolt.org/z/xE1WWW">https://gcc.godbolt.org/z/xE1WWW</a></p>



<a name="212570897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212570897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212570897">(Oct 07 2020 at 15:00)</a>:</h4>
<p>(ignore fn names) the arm is more obviously terrible since you see that:</p>
<ul>
<li>cmp_f has to do extra work to pack up the mask</li>
<li>f_sse then has to unpack it which is nontrivial</li>
</ul>



<a name="212571293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212571293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212571293">(Oct 07 2020 at 15:01)</a>:</h4>
<p>Right-but on SSE you wouldn't want to use narrow masks in the first place</p>



<a name="212571449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212571449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212571449">(Oct 07 2020 at 15:02)</a>:</h4>
<p>i strongly suspect if we provide narrow mask APIs people will use them not realizing they're only efficient on avx512/riscv</p>



<a name="212571591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212571591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212571591">(Oct 07 2020 at 15:03)</a>:</h4>
<p>i mean, i think there's a very strong case to be made that a narrow mask API is a better api — it's a lot simpler and more obvious. it's just aslo... way less efficient on most hardware.</p>



<a name="212572006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212572006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212572006">(Oct 07 2020 at 15:06)</a>:</h4>
<p>it just feels like a bad outcome if we have two versions of most apis</p>
<ul>
<li>one that's simpler but is a performance footgun until AVX512/riscv become widespread</li>
<li>one that is more complex (all those mask types) but will produce essentially optimal code for nearly every ISA, and only be slighly worse than optimal on AVX512/riscv</li>
</ul>



<a name="212572395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212572395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212572395">(Oct 07 2020 at 15:09)</a>:</h4>
<p>i mean i said this last night but, if i were porting code to use the simd API, and i expected <code>f_sse_inlined</code> but got <code>f_sse</code> (from the examples above), i'd probably just assume it was an inefficient API and go back to intrinsics</p>



<a name="212573403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212573403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212573403">(Oct 07 2020 at 15:14)</a>:</h4>
<p>i also think it's worht noting that in reality the majority of users are going to be compiling for stock x86_64/i686 targets for a long time, especially on rust, which means SSE/SSE2.</p>



<a name="212573543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212573543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212573543">(Oct 07 2020 at 15:15)</a>:</h4>
<p>ugh idk we probably should have some way of doing this but it both sucks because of that stuff and just in general it feels very bad to add two API surfaces that do the same thing.</p>



<a name="212573646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212573646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212573646">(Oct 07 2020 at 15:15)</a>:</h4>
<p>you said that avx512 re-exposes a bunch of other stuff to work with 1-bit masks, what about just not exposing that part, and only exposing the new functionality</p>



<a name="212573647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212573647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212573647">(Oct 07 2020 at 15:15)</a>:</h4>
<p>I'm concerned about making too many assumptions for the user.  When you're talking about the level of performance of SIMD you pretty much have to look at generated assembly</p>



<a name="212573804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212573804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212573804">(Oct 07 2020 at 15:16)</a>:</h4>
<p>which part of what i said is an unreasonable assumption?</p>



<a name="212573811"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212573811" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212573811">(Oct 07 2020 at 15:16)</a>:</h4>
<p>I think someone who is writing SIMD to improve performance but not testing for features beyond SSE2 is probably already on the wrong track for most problems</p>



<a name="212574012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212574012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212574012">(Oct 07 2020 at 15:18)</a>:</h4>
<p>i definitely disagree about that, but i also think this is what you have to expect if you provide a portable API</p>



<a name="212574351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212574351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212574351">(Oct 07 2020 at 15:20)</a>:</h4>
<p>i mean: runtime feature checking is a pain, for rust the decision to enable features at compile time is often out of the hands of the person writing SIMD code.</p>



<a name="212574409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212574409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212574409">(Oct 07 2020 at 15:20)</a>:</h4>
<p>If you're working with say f64 and you only use SSE2 you're probably going to be surprised when your SIMD ends up slower</p>



<a name="212574593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212574593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212574593">(Oct 07 2020 at 15:21)</a>:</h4>
<p>Unless of course you have zero shuffles etc</p>



<a name="212574612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212574612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212574612">(Oct 07 2020 at 15:21)</a>:</h4>
<p>sure. and to be clear i'm not saying we can't do better than SSE2 — i hope this ultimately does something to improve runtime feature checking too.</p>



<a name="212574781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212574781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212574781">(Oct 07 2020 at 15:22)</a>:</h4>
<p>Not trying to plug <code>multiversion</code> really, but runtime detection is trivial with something like that</p>



<a name="212574974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212574974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212574974">(Oct 07 2020 at 15:23)</a>:</h4>
<p>yeah, but with multiversion, IIUC if you use an api like this everybody who isn't using AVX512 gets a much slower result. whereas if you used the wider vectors, it would improve much more smoothly as the API availibility increased.</p>



<a name="212575172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212575172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212575172">(Oct 07 2020 at 15:24)</a>:</h4>
<p>You would select algorithms based on instruction set</p>



<a name="212575235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212575235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212575235">(Oct 07 2020 at 15:25)</a>:</h4>
<p>You'll have the exact same problem if you only use 128 bit vectors on wider architectures</p>



<a name="212575263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212575263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212575263">(Oct 07 2020 at 15:25)</a>:</h4>
<p>Or even 64 bit vectors!</p>



<a name="212575528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212575528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212575528">(Oct 07 2020 at 15:26)</a>:</h4>
<p>summarizing the problems i have here</p>
<ul>
<li>it duplicates a huge amount of api surface</li>
<li>the api is appealingly simple in comparison to the one that maps better to hardware, and so i suspect it would be confusing and easy to use accidentally</li>
<li>it's very hard to shim efficiently and will make a lot of surrounding code slower</li>
<li>so you fall off huge performance cliff if you aren't on avx512 (which is extremely rare still)</li>
</ul>



<a name="212575623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212575623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212575623">(Oct 07 2020 at 15:27)</a>:</h4>
<p>i think those problems are decidedly different than choosing to use 128 bit vectors</p>



<a name="212575645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212575645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212575645">(Oct 07 2020 at 15:27)</a>:</h4>
<p>What makes the api simpler? I'm suggesting having nearly identical APIs for both</p>



<a name="212575807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212575807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212575807">(Oct 07 2020 at 15:28)</a>:</h4>
<p>it mostly looks simpler since users are more familiar with "<code>u64</code> acting as a bitmask" than they are with <code>mask8x32</code> or w/e</p>



<a name="212575879"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212575879" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212575879">(Oct 07 2020 at 15:29)</a>:</h4>
<p>Well to them it would just be mask1x32 and mask8x32</p>



<a name="212576024"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212576024" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212576024">(Oct 07 2020 at 15:30)</a>:</h4>
<p>Also given the choice between <code>eq</code> and <code>eq_packed</code> I think <code>eq</code> is more likely to be seen as general purpose</p>



<a name="212576110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212576110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212576110">(Oct 07 2020 at 15:30)</a>:</h4>
<p>We could even provide the packed API as a trait so you explicitly need to opt into it</p>



<a name="212576446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212576446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212576446">(Oct 07 2020 at 15:32)</a>:</h4>
<p>i mean, those would probably help address several of my concerns, but i'm genuinely worried about the "duplicates a huge amount of api surface" part making it harder to get this ultimately accepted (i am worried about this regardless of the outcome here...)</p>



<a name="212576573"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212576573" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212576573">(Oct 07 2020 at 15:33)</a>:</h4>
<p>that said if it's done in a way to avoid the potential for perf footgun, i dont care as much</p>



<a name="212576697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212576697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212576697">(Oct 07 2020 at 15:34)</a>:</h4>
<p>As far as stabilization goes, it doesn't need to all be stabilized at once</p>



<a name="212585144"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212585144" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212585144">(Oct 07 2020 at 16:34)</a>:</h4>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> I have no idea when I am supposed to use each though.</p>



<a name="212585235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212585235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212585235">(Oct 07 2020 at 16:35)</a>:</h4>
<p>One note about using <code>u64</code> or even <code>u128</code> as a lane mask -- RISC-V V supports much more than 128 lanes.<br>
Another note about RISC-V V: IIRC it doesn't guarantee any more than 128-bit vectors last time I checked.</p>



<a name="212585396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212585396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212585396">(Oct 07 2020 at 16:36)</a>:</h4>
<p>Like, you can explain it to me five times, and I get that there are specific instructions, but I am trying to write portable SIMD. Injecting a non-portable concern into my code means that now my code compiles like trash on some architectures and not others, and I don't necessarily know which ones. Yielding these architecture-specific types into non-architecture-specific code is deciding to make the API less portable, and I don't see this actually changing no matter what convolutions are done with the code.</p>



<a name="212585515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212585515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212585515">(Oct 07 2020 at 16:37)</a>:</h4>
<p>This is exactly the problem we are supposed to be solving. Deciding to do so by punting to the programmer to know which architectures they should use which type on is simply not what we should be doing.</p>



<a name="212585605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212585605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212585605">(Oct 07 2020 at 16:38)</a>:</h4>
<p>yes, that's why i'm not a huge fan of adding a duplicate api that's like an existing one except is much slower everywhere but when compiled with avx512</p>



<a name="212585643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212585643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212585643">(Oct 07 2020 at 16:38)</a>:</h4>
<p>It cuts both ways though.</p>



<a name="212585664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212585664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212585664">(Oct 07 2020 at 16:38)</a>:</h4>
<p>Shouldn't we remove integer division and 64-bit vectors for the same reason?</p>



<a name="212585679"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212585679" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212585679">(Oct 07 2020 at 16:39)</a>:</h4>
<p>i mean its only very slightly faster on avx512</p>



<a name="212585693"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212585693" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212585693">(Oct 07 2020 at 16:39)</a>:</h4>
<p>Arm is also extremely limited on immediate shuffles as well</p>



<a name="212585757"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212585757" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212585757">(Oct 07 2020 at 16:39)</a>:</h4>
<p>Sure, let's do it.</p>



<a name="212585811"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212585811" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212585811">(Oct 07 2020 at 16:40)</a>:</h4>
<p>i also very much don't think it follows that when desiginign the API we should not consider the performance of these things across a vareity of targets</p>



<a name="212586000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212586000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212586000">(Oct 07 2020 at 16:42)</a>:</h4>
<p>Though to rebut:<br>
Division is a logical operation, if someone needs the logical operation of division they need it regardless of what the arch support specifically is.<br>
<strong>This is not the same</strong> as masking having an implementation-specific type, where the ultimate logical operation is the same but the hardware implementation details -- the things we're supposed to be abstracting over -- differ.</p>



<a name="212586006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212586006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212586006">(Oct 07 2020 at 16:42)</a>:</h4>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> it's tradeoffs. in this case you gain a small amount of performance on niche hardware, and in exchange you greatly increase the API surface, provide very little that couldn't already be done at close to the same performance, and add performance footguns for everybody else. i really don't think these concerns apply to the cases you keep listing.</p>



<a name="212586136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212586136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212586136">(Oct 07 2020 at 16:43)</a>:</h4>
<p>Another example, neon doesn't have a copysign equivalent afaik</p>



<a name="212586167"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212586167" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212586167">(Oct 07 2020 at 16:43)</a>:</h4>
<p>Again, if someone needs logical copysign they need it regardless of the arch support.</p>



<a name="212586226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212586226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212586226">(Oct 07 2020 at 16:44)</a>:</h4>
<p>copysign is done with bitops</p>



<a name="212586228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212586228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212586228">(Oct 07 2020 at 16:44)</a>:</h4>
<p>Also it's just an &amp; or maybe a XOR...</p>



<a name="212586262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212586262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212586262">(Oct 07 2020 at 16:44)</a>:</h4>
<p>I wouldn't say that's an accurate characterization, it's potentially double the performance for all masked ops</p>



<a name="212586313"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212586313" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212586313">(Oct 07 2020 at 16:44)</a>:</h4>
<p>Also nearly all server hardware has AVX512 now I believe</p>



<a name="212586334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212586334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212586334">(Oct 07 2020 at 16:45)</a>:</h4>
<p>it's way worse than double the cost on everything else though</p>



<a name="212586340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212586340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212586340">(Oct 07 2020 at 16:45)</a>:</h4>
<p>All Intel server hardware.</p>



<a name="212586362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212586362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212586362">(Oct 07 2020 at 16:45)</a>:</h4>
<p>That was sold recently.</p>



<a name="212586398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212586398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212586398">(Oct 07 2020 at 16:45)</a>:</h4>
<p>We're only pessimizing the performance if we hardcode a specific type size, just saying.</p>



<a name="212586516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212586516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212586516">(Oct 07 2020 at 16:46)</a>:</h4>
<p>What do you mean?</p>



<a name="212586578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212586578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212586578">(Oct 07 2020 at 16:46)</a>:</h4>
<p>also double the cost for mask ops is like 1 or two instrucitons each way that i highly suspect (when things are inlined) that LLVM will easily see through. when things aren't inlined or other stuff gets in the way yeah, you add a little bit of overhead.</p>



<a name="212586901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212586901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212586901">(Oct 07 2020 at 16:49)</a>:</h4>
<p>dynamically sized types are things?</p>
<p>As Lokathor said a whiiile back, it's confusing to do blending operations with things that aren't bitmasks. However, we need our mask types to operate the same way in our API regardless of their actual hardware implementation. If a vector implementation doesn't have or prefer bitmasks, then we still need masks to behave the same way in our API regardless of whether they are uints as they are in GPUs or RISCV or movemask, or the Neon/x86 bitmasks, or whatever else someone comes up with.</p>



<a name="212587255"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212587255" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212587255">(Oct 07 2020 at 16:52)</a>:</h4>
<p>Given that it <strong>is</strong> so contentious and performance-sensitive, what I would be really happy with is if we found a way to expose the ability to mask lanes without exposing the actual type at all, frankly.</p>



<a name="212587472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212587472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212587472">(Oct 07 2020 at 16:53)</a>:</h4>
<p>i'm pretty surprised it's this contentious</p>



<a name="212587638"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212587638" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212587638">(Oct 07 2020 at 16:55)</a>:</h4>
<p>idk how you could not expose some sort of comparison result though. i guess you could return an impl trait voldermort type but i think that would make everybody annoyed.</p>



<a name="212587729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212587729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212587729">(Oct 07 2020 at 16:55)</a>:</h4>
<p>(if you meant not exposing the width of the simd lane — i don't think it's possible. if it were this wouldn't be an issue, since the "no lane width" type is morally equivalent to a 1-bit-per-lane type)</p>



<a name="212588014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212588014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212588014">(Oct 07 2020 at 16:58)</a>:</h4>
<p>i also just think the number of people who will jump through the hoops to get their code running on AVX512 via either multiversion or compiling with -Ctarget-foo flags is a very small number of people. realistically it's not great but i think most people will use this exactly how they use anything from the stdlib now, which is to say they'll compile it with default settings (and get SSE2)</p>



<a name="212588104"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212588104" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212588104">(Oct 07 2020 at 16:59)</a>:</h4>
<p>Until someone makes it easy to compile to various arch features.</p>



<a name="212588119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212588119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212588119">(Oct 07 2020 at 16:59)</a>:</h4>
<p>if the library here is designed well presumably we could auto-multiversion for you by just recompile the same source code with higher target features (or something like this).</p>



<a name="212588203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212588203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212588203">(Oct 07 2020 at 16:59)</a>:</h4>
<p>That's exactly what the multiversion crate does</p>



<a name="212588270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212588270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212588270">(Oct 07 2020 at 17:00)</a>:</h4>
<p>Exactly.</p>



<a name="212588341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212588341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212588341">(Oct 07 2020 at 17:00)</a>:</h4>
<p>That is, as we say in the biz,<br>
merely an engineering problem.</p>



<a name="212588417"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212588417" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212588417">(Oct 07 2020 at 17:01)</a>:</h4>
<p>okay, i thought it was, but you later said you needed to use a different algorithm for different arches. which is basically the problem i have with the 1bit mask — its only a good idea if you know the arch you're targeting.</p>



<a name="212588492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212588492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212588492">(Oct 07 2020 at 17:01)</a>:</h4>
<p>Also honestly I don't think I've seen any SIMD code written in the last 10 years that didn't do runtime feature detection</p>



<a name="212588585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212588585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212588585">(Oct 07 2020 at 17:02)</a>:</h4>
<p>Not to say people don't and won't, but I don't think that's a good argument for excluding newer architectures</p>



<a name="212588698"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212588698" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212588698">(Oct 07 2020 at 17:03)</a>:</h4>
<p>Teaching people how to use SIMD Masks is not, however, so trivial a problem, and if you're arguing for an expansion of specific typesin the code, because it's performance sensitive and they have to use it correctly and they have to only use certain types on certain arches...</p>



<a name="212588801"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212588801" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212588801">(Oct 07 2020 at 17:03)</a>:</h4>
<p>uh<br>
I'm going to be frank I don't know how to teach people to do that.</p>



<a name="212589006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212589006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212589006">(Oct 07 2020 at 17:05)</a>:</h4>
<p>Also people work with Voldemort types all the time. :P</p>



<a name="212589036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212589036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212589036">(Oct 07 2020 at 17:05)</a>:</h4>
<p><span class="user-mention silent" data-user-id="229517">Jacob Lifshay</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20movemasquerade/near/212517150">said</a>:</p>
<blockquote>
<p>we could also just define <code>m8x16</code> to be either <code>&lt;16 x i1&gt;</code> or <code>&lt;16 x i8&gt;</code> depending on the architecture and define a <code>fullmask8x16</code> when the user explicitly wants <code>&lt;16 x i8&gt;</code></p>
</blockquote>
<p>I still think this is probably the best solution to handling masks for fixed-width SIMD</p>



<a name="212589260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212589260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212589260">(Oct 07 2020 at 17:07)</a>:</h4>
<p>i think having 2 sets of mask types would be bad. i also think having the types layout radically change depending on architecture would be pretty bad, and from what i've seen LLVM doesn't really do a great job with <code>&lt;N x i1&gt;</code> code...</p>



<a name="212589369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212589369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212589369">(Oct 07 2020 at 17:08)</a>:</h4>
<p>Fwiw if you dont know anything about SIMD I think you will still run into some problems with performance anyway. I imagine that the overlap of people who write branch free code but don't know SIMD is already very low</p>



<a name="212589437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212589437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212589437">(Oct 07 2020 at 17:08)</a>:</h4>
<p>I don't think so?</p>



<a name="212589609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212589609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212589609">(Oct 07 2020 at 17:10)</a>:</h4>
<p><span class="user-mention silent" data-user-id="209168">Thom Chiovoloni</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20movemasquerade/near/212589260">said</a>:</p>
<blockquote>
<p>i think having 2 sets of mask types would be bad. i also think having the types layout radically change depending on architecture would be pretty bad, and from what i've seen LLVM doesn't really do a great job with <code>&lt;N x i1&gt;</code> code...</p>
</blockquote>
<p>From what I can see, it only does a bad job with <code>&lt;16 x i1&gt;</code> types on architectures that use <code>&lt;16 x i8&gt;</code> masks, it should be fine on architectures that natively support <code>&lt;16 x i1&gt;</code> as their preferred mask format.</p>



<a name="212589937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212589937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212589937">(Oct 07 2020 at 17:12)</a>:</h4>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> That's a frankly elitist assumption that is unfounded. Entire programming languages are noted to contribute to trivially more parallelizable code because of stream fusion, and some people learned and program exclusively in those languages, and one of the notable contribution backgrounds to Rust is from those languages.</p>



<a name="212590019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212590019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212590019">(Oct 07 2020 at 17:13)</a>:</h4>
<p>Well, <code>usize</code> radically changes between different architectures, but it hasn't caused many problems...</p>



<a name="212590227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212590227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212590227">(Oct 07 2020 at 17:14)</a>:</h4>
<p><span class="user-mention" data-user-id="281757">@Jubilee</span> I didn't mean to imply that there aren't people who do it, but I am still pretty sure that the vast majority of branch free code is in the context of SIMD</p>



<a name="212590338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212590338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212590338">(Oct 07 2020 at 17:15)</a>:</h4>
<p>But the average rust user is going to be probably familiar with branching code, especially with the prevalence of <code>match</code> etc</p>



<a name="212590477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212590477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212590477">(Oct 07 2020 at 17:16)</a>:</h4>
<p>i think the disagreement here is: i am okay trading fairly small amounts of performance on a few ISAs (even if they're the "newer" ones) if it means the API is simpler, and most code still has zero-cost operations. </p>
<p>i genuinely think this is unavoidable in a portable api in some cases. i don't think there's a hard and fast rule for it, but... if something will double the size of an already complex part of the API it <em>reallllly</em> has to justify itself IMO</p>



<a name="212590738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212590738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212590738">(Oct 07 2020 at 17:18)</a>:</h4>
<p>I think this was mentioned in a different thread, but it's a disagreement over whether _all_ of portable SIMD's code should be mostly optimal, vs should it be  capable of producing valid code on all platforms and optimal on each depending on algorithm</p>



<a name="212590877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212590877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212590877">(Oct 07 2020 at 17:19)</a>:</h4>
<p>"but I am still pretty sure that the vast majority of branch free code is in the context of SIMD" that's plainly false, there are fields that want to write branch free code with or without SIMD parallelization.</p>



<a name="212591029"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212591029" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212591029">(Oct 07 2020 at 17:20)</a>:</h4>
<p>( e.g. cryptography. )<br>
and there are vector processor targeting languages which, er, do not concern themselves with this level of API detail.</p>



<a name="212591086"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212591086" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212591086">(Oct 07 2020 at 17:21)</a>:</h4>
<p>True, it's relevant for timing attacks etc but I think that's relatively niche too</p>



<a name="212591117"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212591117" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212591117">(Oct 07 2020 at 17:21)</a>:</h4>
<p>That is uh, not how cryptographers view it.</p>



<a name="212591258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212591258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212591258">(Oct 07 2020 at 17:22)</a>:</h4>
<p>I think the real elephant in the room is WebGL shader authors who do write explicit masking ops but are pretty OK with having it be a fairly abstract operation.</p>



<a name="212591283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212591283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212591283">(Oct 07 2020 at 17:22)</a>:</h4>
<p>I'm just looking at it from the point of view of the average rust developer. The average rust developer isn't going to know cryptography or SIMD. Some certainly will but I really doubt the average developer does, and we should be supporting average developers too</p>



<a name="212591412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212591412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212591412">(Oct 07 2020 at 17:24)</a>:</h4>
<p>And even with portable SIMD it's still very easy to write very poor vectorized code if you're not aware of the quirks</p>



<a name="212591460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212591460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212591460">(Oct 07 2020 at 17:24)</a>:</h4>
<p>Could we please not think about "average" developers? Because there are no "average developers". There are different groups with different needs, you can extract an LCD but the modal developer is going to have a fairly large amount of specialized skills.</p>



<a name="212591618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212591618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212591618">(Oct 07 2020 at 17:25)</a>:</h4>
<p>this sounds snarky and i mean it respectfully: i don't know how you can think that adding a new separate family of simd masking types would help a developer with a no-more-than-typical level of familiarity with simd</p>



<a name="212591656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212591656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212591656">(Oct 07 2020 at 17:25)</a>:</h4>
<p>I didn't mean average in a derogatory sense, I meant if you split all rust developers into groups of those familiar and unfamiliar with SIMD most will be in the latter group</p>



<a name="212591739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212591739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212591739">(Oct 07 2020 at 17:26)</a>:</h4>
<p>Because it's definitely not a common focus</p>



<a name="212591908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212591908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212591908">(Oct 07 2020 at 17:27)</a>:</h4>
<p>i think to act in that groups best interest we probably want to avoid duplicate funtionality in the api where possible, since that always confusing at all/most levels of familiarity (imo anyway)</p>



<a name="212592013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212592013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212592013">(Oct 07 2020 at 17:28)</a>:</h4>
<p>My point isn't that it helps them, it definitely doesn't, my point is that some level of familiarity is going to be necessary to use portable SIMD regardless of how we end up handling masks, and it's probably more of an issue of education (a portable SIMD mdbook?) than API, in my opinion</p>



<a name="212592033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212592033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212592033">(Oct 07 2020 at 17:28)</a>:</h4>
<p>The two are not separate, actually.</p>



<a name="212592114"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212592114" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212592114">(Oct 07 2020 at 17:29)</a>:</h4>
<p>And are you going to write the entire section on masking and answer all the questions about it for the next 3 years?</p>



<a name="212592191"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212592191" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212592191">(Oct 07 2020 at 17:29)</a>:</h4>
<p>Haha, maybe</p>



<a name="212592582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212592582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212592582">(Oct 07 2020 at 17:32)</a>:</h4>
<p>I speak from experience from having directly mentored many, many people: That is not a trivial act. You are going to have to discard your notions of "average Rust developers"... even "average levels of SIMD familiarity"... really quickly.</p>



<a name="212593247"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212593247" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212593247">(Oct 07 2020 at 17:37)</a>:</h4>
<p>like, there's basically a spectrum of possible designs of stdsimd, and we're coming at it with different opinions on where we want it to be.</p>
<ol>
<li>at one end is bacially: safe_arch but portable (expose everything, polyfill, broadly don't worry about coherency but do try to make the pieces rusty if possible)</li>
<li>the other end is something more like wasm simd  (when in doubt, don't expose it, keep things simple even if limited)</li>
</ol>
<p>(and there's certainly more axes about what things we'd be willing to trade off on and such)</p>
<p>I'm in the middle, but towrds the safe_arch side. i think exposing functionality is generally better, but it has to be weighed against a bunch of other metrics like complexity, understandability, performance, etc.</p>



<a name="212593309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212593309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212593309">(Oct 07 2020 at 17:37)</a>:</h4>
<p>but i think theres a problem we have in that there's basically no agreement at all about this, which is a pretty core piece of the mission statement.</p>



<a name="212593378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212593378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212593378">(Oct 07 2020 at 17:38)</a>:</h4>
<p>and thats why even a small thing like masking has caused so much controversy</p>



<a name="212593557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212593557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212593557">(Oct 07 2020 at 17:39)</a>:</h4>
<p>Yeah, I think that's the core of the problem</p>



<a name="212593690"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212593690" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212593690">(Oct 07 2020 at 17:40)</a>:</h4>
<p>I feel like I am being painted into the "WASM SIMD" corner, so I will say simply: I am not arguing for that.<br>
I am arguing for what was in the announcement post we agreed on:<br>
<a href="https://blog.rust-lang.org/inside-rust/2020/09/29/Portable-SIMD-PG.html">https://blog.rust-lang.org/inside-rust/2020/09/29/Portable-SIMD-PG.html</a></p>
<blockquote>
<p>The portable SIMD API will enable writing SIMD code just once using a high-level API. By explicitly communicating your intent to the compiler, it's better able to generate the best possible final code. This is still only a best-effort process. If your target doesn't support a desired operation in SIMD, the compiler will fall back to using scalar code, processing one lane at a time. The details of what's available depend on the build target.</p>
</blockquote>



<a name="212593708"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212593708" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212593708">(Oct 07 2020 at 17:40)</a>:</h4>
<p>yeah sorry <span class="user-mention" data-user-id="281757">@Jubilee</span>, i suspect you're closer to the 2nd side than I am and I don't feel like i did a good job explaining your poitn</p>



<a name="212593810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212593810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212593810">(Oct 07 2020 at 17:41)</a>:</h4>
<blockquote>
<p>We will cover as many use cases as we can, but it might still be appropriate for you to use std::arch directly. For that reason the std::simd types will also be easily convertable to std::arch types where needed.</p>
</blockquote>
<p>conversion, not 1 = 1</p>



<a name="212593925"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212593925" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212593925">(Oct 07 2020 at 17:42)</a>:</h4>
<p>and easy, not always and forever 0-cost for all possible conversions</p>



<a name="212593935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212593935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212593935">(Oct 07 2020 at 17:42)</a>:</h4>
<p>To be fair, to me that means it would be perfectly appropriate (but certainly not required) to support narrow masks and on unsupported platforms allow it to fall back to scalar code</p>



<a name="212594009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212594009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212594009">(Oct 07 2020 at 17:43)</a>:</h4>
<p>I'm not sure it's definitive in either direction</p>



<a name="212594030"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212594030" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212594030">(Oct 07 2020 at 17:43)</a>:</h4>
<p>i think that statement is pretty vague unfortunately. or, fundamentally i kind of feel like it's unrealistic to push everything here into the compiler</p>



<a name="212594165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212594165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212594165">(Oct 07 2020 at 17:44)</a>:</h4>
<p>From "high-level", I discern that my first concern is making sure that the API is higher-level than specific vendor intrinsics, which is why I'm wary of the approach that seems to argue for things mostly in the context of vendor intrinsics.</p>



<a name="212594241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212594241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212594241">(Oct 07 2020 at 17:45)</a>:</h4>
<p><span class="user-mention silent" data-user-id="209168">Thom Chiovoloni</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20movemasquerade/near/212591618">said</a>:</p>
<blockquote>
<p>this sounds snarky and i mean it respectfully: i don't know how you can think that adding a new separate family of simd masking types would help a developer with a no-more-than-typical level of familiarity with simd</p>
</blockquote>
<p>So, would you be happier with just the <code>m8x16</code> type that is either <code>&lt;16 x i8&gt;</code> or <code>&lt;16 x i1&gt;</code> depending on the particular architecture, without the <code>fullmask8x16</code> type? I think that's probably the core part of my proposal.</p>



<a name="212594346"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212594346" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212594346">(Oct 07 2020 at 17:46)</a>:</h4>
<p>I believe there are higher-level patterns that can be relied on, and Jacob has been pretty astute in identifying how those can be sliced between arches, probably because they have the most, er, implementation side experience with hardware.</p>



<a name="212594552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212594552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212594552">(Oct 07 2020 at 17:47)</a>:</h4>
<p><span class="user-mention" data-user-id="229517">@Jacob Lifshay</span> i'm certainly more comfortable with it. especially if it is based on the arch, since i think handling levels of feature support would complicate things a lot.</p>



<a name="212594569"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212594569" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212594569">(Oct 07 2020 at 17:47)</a>:</h4>
<p>I'm not sure you can simply divide it by architecture since Intel (like it or not, a major piece of market share) supports both paradigms</p>



<a name="212594690"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212594690" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212594690">(Oct 07 2020 at 17:48)</a>:</h4>
<p>I mean so does AMD, and if anything I am a partisan for them.</p>



<a name="212594746"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212594746" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212594746">(Oct 07 2020 at 17:49)</a>:</h4>
<p>I just meant intel since they designed the extension, but yeah really x86-64 as a whole</p>



<a name="212594869"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212594869" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212594869">(Oct 07 2020 at 17:50)</a>:</h4>
<p>It further complicates things that if you're reaching for performance you'll want a different mask than if you're aiming for compatibility</p>



<a name="212595026"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212595026" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212595026">(Oct 07 2020 at 17:51)</a>:</h4>
<p>As far as I see it, a slightly more opaque API on the mask end is mostly useful <em>as a lever to</em> achieve better performance overall.</p>



<a name="212595108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212595108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212595108">(Oct 07 2020 at 17:52)</a>:</h4>
<p>I also don't think we can just swap masks on different architectures because wide masks can be transmuted to integer vectors and can be referenced as slices, and narrow vectors can't</p>



<a name="212595231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212595231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212595231">(Oct 07 2020 at 17:53)</a>:</h4>
<p>I wouldn't be opposed to something like a mask trait and functions return <code>impl Mask</code>, but I still think you should have access to explicitly wide and narrow masks as well</p>



<a name="212595896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212595896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212595896">(Oct 07 2020 at 17:58)</a>:</h4>
<p>My brain just offered this extremely cursed thought, so you all get to share in it:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">use</span><span class="w"> </span><span class="n">std</span>::<span class="n">arch</span>::<span class="n">x86_64</span>::<span class="n">MaskExt</span><span class="p">;</span><span class="w"></span>
</code></pre></div>



<a name="212597365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212597365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212597365">(Oct 07 2020 at 18:10)</a>:</h4>
<p>I believe that, as usual with these things, we actually agree more than we disagree, but we are having trouble expressing the finer points of our agreements which are probably more important than the finer points of our disagreements.</p>



<a name="212599217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212599217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212599217">(Oct 07 2020 at 18:25)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20movemasquerade/near/212595108">said</a>:</p>
<blockquote>
<p>I also don't think we can just swap masks on different architectures because wide masks can be transmuted to integer vectors and can be referenced as slices, and narrow vectors can't</p>
</blockquote>
<p>Can't we just say <code>m8x16</code> has platform-specific layout and provide methods to convert from/to wide masks (<code>u8x16</code> or some mask-specific type) as well as narrow masks (either <code>u16</code> or some mask-specific type)?</p>



<a name="212599254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212599254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212599254">(Oct 07 2020 at 18:25)</a>:</h4>
<p>or even unspecified layout</p>



<a name="212599440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212599440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212599440">(Oct 07 2020 at 18:27)</a>:</h4>
<p>allowing us to use narrow masks with AVX512F and wide masks with AVX2 (assuming the compiler wants to implement that)</p>



<a name="212599520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212599520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212599520">(Oct 07 2020 at 18:27)</a>:</h4>
<p>i mean you can bring the result of one mask operation elsewhere so idk how different layouts for those would work</p>



<a name="212599564"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212599564" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212599564">(Oct 07 2020 at 18:28)</a>:</h4>
<p>unless they're different types</p>



<a name="212599588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212599588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212599588">(Oct 07 2020 at 18:28)</a>:</h4>
<p>where it switches the layout based on the enabled features</p>



<a name="212599595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212599595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212599595">(Oct 07 2020 at 18:28)</a>:</h4>
<p>i'm fine with it being arch specific though honestly</p>



<a name="212599833"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212599833" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212599833">(Oct 07 2020 at 18:30)</a>:</h4>
<p>you mean enabled at compile time?</p>



<a name="212599838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212599838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212599838">(Oct 07 2020 at 18:30)</a>:</h4>
<p>we'd want to have some logic for picking the in-memory layout based only on the global feature set, not the per-function features though, otherwise we end up with a problem</p>



<a name="212599885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212599885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212599885">(Oct 07 2020 at 18:30)</a>:</h4>
<p>There's no way to change layout depending on target feature</p>



<a name="212599959"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212599959" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212599959">(Oct 07 2020 at 18:31)</a>:</h4>
<p>compiler can be extended to add that? it knows the target features when calculating layout</p>



<a name="212599981"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212599981" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212599981">(Oct 07 2020 at 18:31)</a>:</h4>
<p>And I think it's unlikely we can add that support either, most features like that have been deferred until rust has a hypothetical effects system</p>



<a name="212599992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212599992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212599992">(Oct 07 2020 at 18:31)</a>:</h4>
<p>global features, that is</p>



<a name="212600101"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212600101" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212600101">(Oct 07 2020 at 18:32)</a>:</h4>
<p>I don't think global feature set would work because core/std is delivered compiled</p>



<a name="212600146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212600146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212600146">(Oct 07 2020 at 18:32)</a>:</h4>
<p>yeah according to  <a href="https://rust-lang.github.io/rfcs/2045-target-feature.html">https://rust-lang.github.io/rfcs/2045-target-feature.html</a> the <code>cfg</code> value varies depending on which features have been enabled</p>
<blockquote>
<p>In a function annotated with #[target_feature(enable = "feature_name")] the macro cfg!(target_feature = "feature_name") expands to true if the generated code for the function uses the feature</p>
</blockquote>



<a name="212600202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212600202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212600202">(Oct 07 2020 at 18:33)</a>:</h4>
<p>That never actually made it to implementation</p>



<a name="212600233"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212600233" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212600233">(Oct 07 2020 at 18:33)</a>:</h4>
<p>okay that makes a lot more sense</p>



<a name="212600264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212600264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212600264">(Oct 07 2020 at 18:33)</a>:</h4>
<p>that said it could in the future maybe idk</p>



<a name="212600311"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212600311" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212600311">(Oct 07 2020 at 18:34)</a>:</h4>
<p>There is no way to detect the current target features, and likely no way in the near future unfortunately</p>



<a name="212600403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212600403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212600403">(Oct 07 2020 at 18:34)</a>:</h4>
<p>Would definitely solve a lot of headaches but I get why it's so hard to implement</p>



<a name="212600411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212600411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212600411">(Oct 07 2020 at 18:34)</a>:</h4>
<p>not from rust source code, but the compiler knows -- it calculates the layout in the same process after all</p>



<a name="212600489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212600489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212600489">(Oct 07 2020 at 18:35)</a>:</h4>
<p>It doesn't know what function you have been inlined into afaik</p>



<a name="212600638"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212600638" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212600638">(Oct 07 2020 at 18:36)</a>:</h4>
<p>target_feature's design is pretty annoying tbh but it very much beats the situation in c/c++ where you have to compile everything separately and pray</p>



<a name="212600800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212600800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212600800">(Oct 07 2020 at 18:37)</a>:</h4>
<p>if that doesn't work, we could just have it use the same in-memory layout for the arch and in the function ABI lowering convert vectors passed by value to the appropriate ABI -- just like the ABI of <code>f32x16</code> changes in C compilers if you enable/disable AVX512f</p>



<a name="212600816"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212600816" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212600816">(Oct 07 2020 at 18:37)</a>:</h4>
<p>Actually I think it's nearly identical to target attributes in gcc and clang</p>



<a name="212601024"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212601024" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212601024">(Oct 07 2020 at 18:39)</a>:</h4>
<p>I think at that point I would just prefer a completely opaque type and not support AVX512</p>



<a name="212603419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212603419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212603419">(Oct 07 2020 at 18:57)</a>:</h4>
<p>so two notes: you can change the layout of a struct based on compile time features.</p>



<a name="212603568"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212603568" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212603568">(Oct 07 2020 at 18:58)</a>:</h4>
<p>and two: i've yet to see <em>any</em> argument against having wide masks available everywhere and optional narrow masks as an extension you sometimes use</p>



<a name="212605207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212605207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212605207">(Oct 07 2020 at 19:09)</a>:</h4>
<p>bigger api/more complex surface mostly.</p>



<a name="212605395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212605395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212605395">(Oct 07 2020 at 19:10)</a>:</h4>
<p>but yes i was okay with this so long as it's not confusing which is the extension and which is the main api you're expected to work with.</p>



<a name="212605424"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212605424" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212605424">(Oct 07 2020 at 19:11)</a>:</h4>
<p>but only people who delve into the extra layer care. this would be comparable to std::fs or whatever having unix and windows extensions. i just ignore those modules because i don't care to get into it.</p>



<a name="212605562"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212605562" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212605562">(Oct 07 2020 at 19:12)</a>:</h4>
<p>it being like std::fs::unix implies it's not portable and we do kinda already have the nonportable simd api</p>



<a name="212606197"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212606197" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212606197">(Oct 07 2020 at 19:16)</a>:</h4>
<p>uh, partly. it might be better to say that with enough PRs we will some day have avx512 coverage (and the simpleV arch stuff as well, again, "someday").</p>



<a name="212606289"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212606289" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212606289">(Oct 07 2020 at 19:17)</a>:</h4>
<p>oh right avx512 isnt there</p>



<a name="212606341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212606341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212606341">(Oct 07 2020 at 19:17)</a>:</h4>
<p>so i propose that we continue with wide masks, and then as an extension we can also support narrow masks, possibly to be stabilized separately because just generally the narrow mask targets are pretty experimentqal</p>



<a name="212606414"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212606414" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212606414">(Oct 07 2020 at 19:18)</a>:</h4>
<p>fwiw RISCV-V is not SimpleV for note.<br>
and GPUs aren't really experimental?</p>



<a name="212606418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212606418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212606418">(Oct 07 2020 at 19:18)</a>:</h4>
<p>honestly at this point my will to have an opinion on masking has eroded so it sounds fine.</p>



<a name="212606431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212606431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212606431">(Oct 07 2020 at 19:18)</a>:</h4>
<p>&lt;_&lt;;</p>



<a name="212606488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212606488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212606488">(Oct 07 2020 at 19:18)</a>:</h4>
<p>aaaa.<br>
I don't think we should be making hard decisions atm.</p>



<a name="212606548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212606548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212606548">(Oct 07 2020 at 19:19)</a>:</h4>
<p>GPUs aren't experimental, but mixing code across GPUs, avx512, and simplev (or whatever it's called) <em>is experimental</em>, and so that's why we'd put it on hold</p>



<a name="212606591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212606591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212606591">(Oct 07 2020 at 19:19)</a>:</h4>
<p>That's True.</p>



<a name="212606604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212606604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212606604">(Oct 07 2020 at 19:19)</a>:</h4>
<p>(anyway sorry if i contributed to any bad vibes in this discussion, i feel like i might have unintentionally)</p>



<a name="212606606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212606606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212606606">(Oct 07 2020 at 19:19)</a>:</h4>
<p>right, the best part about putting things on hold is that it's not a hard decision. you can always just take a thing off hold later</p>



<a name="212606786"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212606786" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212606786">(Oct 07 2020 at 19:21)</a>:</h4>
<p>I basically am just mentally moving my internal estimate of where our "stabilize masks" date will be out to closer to our "stabilize floats" date, which is after our "stabilize uints/sints" date.</p>



<a name="212607090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212607090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212607090">(Oct 07 2020 at 19:23)</a>:</h4>
<p>by stabilize you mean like, decide on? (i dont really think we should land something like on stable with gaps quite that big)</p>



<a name="212607212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212607212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212607212">(Oct 07 2020 at 19:24)</a>:</h4>
<p>I think we can stabilize wide masks and delay narrow masks as long as we come to a conclusion that they are definitely different things, even if we don't decide how narrow masks are handled</p>



<a name="212607256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212607256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212607256">(Oct 07 2020 at 19:25)</a>:</h4>
<p>...hrm.<br>
I do not know how to communicate, I feel like.</p>



<a name="212607283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212607283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212607283">(Oct 07 2020 at 19:25)</a>:</h4>
<p>sorry i think i got it</p>



<a name="212615626"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212615626" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212615626">(Oct 07 2020 at 20:34)</a>:</h4>
<p><span class="user-mention silent" data-user-id="224471">Lokathor</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20movemasquerade/near/212606341">said</a>:</p>
<blockquote>
<p>so i propose that we continue with wide masks, and then as an extension we can also support narrow masks, possibly to be stabilized separately because just generally the narrow mask targets are pretty experimentqal</p>
</blockquote>
<p>I think it's fine to start out only with types that look like wide masks, but on targets such as RISC-V V those types should instead be narrow masks inside, since narrow masks are waay more efficient on RISC-V V and similar to the extent that I don't think bitwise logical ops are supported on float vectors without converting to a narrow mask first or converting the float vector to an integer vector, both of which can cost extra cycles.</p>
<p>This wouldn't mean much at the API level for now other than transmutation between mask types and other vectors is not defined to always work, you just have to use conversions instead. The other difference is mostly just documentation.</p>



<a name="212617765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212617765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212617765">(Oct 07 2020 at 20:54)</a>:</h4>
<p>Shouldn't you just prefer to use the narrow masks in that situation then? Rather than type trickery</p>



<a name="212619200"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212619200" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212619200">(Oct 07 2020 at 21:06)</a>:</h4>
<p>yeah, if a device has no floating point unit and you have to do software floats instead, but <em>also</em> you could do fixed point, we'd just offer fixed point and leave the decision of when to swap over to the user. we wouldn't make normal floats magically change to fixed point in the background on you.</p>



<a name="212635646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212635646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212635646">(Oct 08 2020 at 00:22)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20movemasquerade/near/212617765">said</a>:</p>
<blockquote>
<p>Shouldn't you just prefer to use the narrow masks in that situation then? Rather than type trickery</p>
</blockquote>
<p>no, because you'd want your code to be portable between SSE2 and similar and RISC-V V.</p>



<a name="212635806"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212635806" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212635806">(Oct 08 2020 at 00:25)</a>:</h4>
<p><span class="user-mention silent" data-user-id="224471">Lokathor</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20movemasquerade/near/212619200">said</a>:</p>
<blockquote>
<p>yeah, if a device has no floating point unit and you have to do software floats instead, but <em>also</em> you could do fixed point, we'd just offer fixed point and leave the decision of when to swap over to the user. we wouldn't make normal floats magically change to fixed point in the background on you.</p>
</blockquote>
<p>There's an important difference between your example and what I'm proposing: in your example the operations produce fundamentally different results, in what i'm proposing the results are exactly the same, only the representation is different.</p>



<a name="212635828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212635828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212635828">(Oct 08 2020 at 00:25)</a>:</h4>
<p>I think you could abstract a subset of features in common with narrow and wide masks and use the same code on all architectures (with a trait)</p>



<a name="212635881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212635881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212635881">(Oct 08 2020 at 00:26)</a>:</h4>
<p>But in many cases you want to have a known layout of the mask so you can transmute/convert it i think</p>



<a name="212635908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212635908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212635908">(Oct 08 2020 at 00:27)</a>:</h4>
<p>some numbers can be represented in fp but not fixed point and vis versa. however, the two kinds of masks are 1:1 isomorphic.</p>



<a name="212636009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212636009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212636009">(Oct 08 2020 at 00:29)</a>:</h4>
<p>I imagine there are even times with RISC-V you may want your comparison results to have lane width so you can transmute them to integers</p>



<a name="212636012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212636012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212636012">(Oct 08 2020 at 00:29)</a>:</h4>
<p>Or to floats</p>



<a name="212636079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212636079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212636079">(Oct 08 2020 at 00:30)</a>:</h4>
<p>Just as with other architectures it is sometimes useful to convert the narrow masks to a single integer</p>



<a name="212636115"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212636115" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212636115">(Oct 08 2020 at 00:31)</a>:</h4>
<p>thinking a bit more another issue with e.g. <code>m16x8</code> changing its layout to <code>&lt;i1 x 8&gt;</code> on riscv is that it would be pretty reasonable for user code to assume <code>m16x8</code> is a type which has a well defined and reliable layout, given that it looks a ton like <code>i16x8</code>/<code>u16x8</code> which are this way... eg.. I'm worried about unsafe code doing things and then being unsound on riscv</p>



<a name="212636126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212636126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212636126">(Oct 08 2020 at 00:31)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20movemasquerade/near/212635881">said</a>:</p>
<blockquote>
<p>But in many cases you want to have a known layout of the mask so you can transmute/convert it i think</p>
</blockquote>
<p>then what you do is call the conversion function provided by <code>stdsimd</code> that converts from <code>m8x16</code> to <code>u8x16</code> if you want wide masks and to <code>u16</code> or some other type if you want narrow masks. This is kinda like <code>OsString</code> is internally UTF-8 (actually WTF-8) but on windows platforms can be converted to windows standard UTF-16 (mostly -- actually a nearly arbitrary sequence of u16)</p>



<a name="212636229"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212636229" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212636229">(Oct 08 2020 at 00:33)</a>:</h4>
<p>Right, but if you are 90% there the loss of support for AVX512 at that point seems arbitrary</p>



<a name="212636301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212636301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212636301">(Oct 08 2020 at 00:34)</a>:</h4>
<p>When this is definitely solved by a mask trait and conditionally compiled functions that use <code>impl Mask</code></p>



<a name="212636303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212636303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212636303">(Oct 08 2020 at 00:34)</a>:</h4>
<p><span class="user-mention silent" data-user-id="209168">Thom Chiovoloni</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20movemasquerade/near/212636115">said</a>:</p>
<blockquote>
<p>thinking a bit more another issue with e.g. <code>m16x8</code> changing its layout to <code>&lt;i1 x 8&gt;</code> on riscv is that it would be pretty reasonable for user code to assume <code>m16x8</code> is a type which has a well defined and reliable layout, given that it looks a ton like <code>i16x8</code>/<code>u16x8</code> which are this way... eg.. I'm worried about unsafe code doing things and then being unsound on riscv</p>
</blockquote>
<p>we can add lints to catch bad transmutes (suggesting conversion to the provided <code>convert</code> functions) and explicitly state that they have unspecified layout in the docs</p>



<a name="212636352"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212636352" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212636352">(Oct 08 2020 at 00:35)</a>:</h4>
<p>we can also pick a different naming scheme if you think that might help, but I think the default mask type should be whatever <code>m8x16</code> and friends is renamed to</p>



<a name="212636440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212636440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212636440">(Oct 08 2020 at 00:36)</a>:</h4>
<p>if we're going to do something fairly atypical like <code>impl Mask</code> i suspect we should try to quickly get to a point where the library can be used to write sample code (even if lots of other stuff is still subject to change), to flush out issues with te design. this is probably a good idea regardless...</p>



<a name="212636462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212636462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212636462">(Oct 08 2020 at 00:37)</a>:</h4>
<p>You could even provide both wide and narrow masks as separate extension traits and purely use <code>impl Mask</code> as the default--in that case we don't favor a single implementation</p>



<a name="212636535"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212636535" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212636535">(Oct 08 2020 at 00:38)</a>:</h4>
<p>honestly i'm pretty skeptical of a design which fundamentally from being able to store a mask in a struct or w/e because it's an impl Trait</p>



<a name="212636545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212636545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212636545">(Oct 08 2020 at 00:38)</a>:</h4>
<p>or in an array, etc.</p>



<a name="212636581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212636581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212636581">(Oct 08 2020 at 00:39)</a>:</h4>
<p>What I'm proposing is that you can have access to each type if you choose, with the implications of each, but by default it's purely an opaque type and you don't necessarily know which you have</p>



<a name="212636680"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212636680" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212636680">(Oct 08 2020 at 00:40)</a>:</h4>
<p>Instead of a trait it could be an opaque type with unspecified layout, since that would solve some of the current limitations of impl trait</p>



<a name="212636692"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212636692" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212636692">(Oct 08 2020 at 00:40)</a>:</h4>
<p>what about providing 3 types to cover all the special cases: <code>mask8x16</code>, <code>widemask8x16</code>, and <code>bitmaskx16</code>? obviously the names could use some help :)</p>



<a name="212636736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212636736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212636736">(Oct 08 2020 at 00:41)</a>:</h4>
<p>that's a very large api surface area...</p>



<a name="212636740"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212636740" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212636740">(Oct 08 2020 at 00:41)</a>:</h4>
<p>Yeah that may actually work, I think that's a balance of the suggestions you and <span class="user-mention" data-user-id="281757">@Jubilee</span> proposed with an opaque type, and the extension trait version I'm a fan of</p>



<a name="212636805"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212636805" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212636805">(Oct 08 2020 at 00:42)</a>:</h4>
<p>Yeah, it is large, but I think the wide and bitmasks can be relegated to extension traits to make them easy to ignore until you need them</p>



<a name="212636809"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212636809" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212636809">(Oct 08 2020 at 00:42)</a>:</h4>
<p>i would very strongly prefer to avoid any more unspecified layout types</p>



<a name="212636838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212636838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212636838">(Oct 08 2020 at 00:43)</a>:</h4>
<p>How do you feel about impl trait instead?</p>



<a name="212636901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212636901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212636901">(Oct 08 2020 at 00:44)</a>:</h4>
<p>yeah i don't want it to be unspecified. i also don't want masking to be over half of the api surface but i guess i liek a bunch of concrete types slightly more than i like it being a <code>impl Trait</code></p>



<a name="212636994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212636994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212636994">(Oct 08 2020 at 00:46)</a>:</h4>
<p>what about defining the generic mask type to be a repr(transparent) wrapper around one of the other mask types? it would have a associated type with the wrapped mask type. we could also potentially have cfg flags for which kind of masks is default, kinda like the cfg flags for which atomic widths are supported</p>



<a name="212637070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212637070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212637070">(Oct 08 2020 at 00:48)</a>:</h4>
<p>That would make it very easy to write code that compiles on some architectures but not others</p>



<a name="212637071"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212637071" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212637071">(Oct 08 2020 at 00:48)</a>:</h4>
<p>if i'm being totally honest, it feels like an unreasonable amount of complexity to throw at the problem</p>



<a name="212637091"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212637091" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212637091">(Oct 08 2020 at 00:49)</a>:</h4>
<p>(... eh, i should stop for a bit, this is just driving me crazy)</p>



<a name="212637108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212637108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212637108">(Oct 08 2020 at 00:49)</a>:</h4>
<p>SIMD is messy</p>



<a name="212637286"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212637286" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212637286">(Oct 08 2020 at 00:52)</a>:</h4>
<p>The impl trait solution would actually only duplicate the API (which is extra complexity, yes, but not too bad).  You could make a mask trait, which abstracts over masks, and a mask extension trait that provides the API over normal vectors</p>



<a name="212637318"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212637318" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212637318">(Oct 08 2020 at 00:53)</a>:</h4>
<p>my concern for impl trait is mostly ergonomics. it's also pretty uncommon to find in stdlib apis.</p>



<a name="212637329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212637329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212637329">(Oct 08 2020 at 00:53)</a>:</h4>
<p>Then you can copy the extension trait methods as inherent methods that return impl Mask</p>



<a name="212637368"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212637368" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212637368">(Oct 08 2020 at 00:54)</a>:</h4>
<p>I agree it's not the best ergonomics</p>



<a name="212637387"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212637387" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212637387">(Oct 08 2020 at 00:54)</a>:</h4>
<p>At least not on stable yet</p>



<a name="212637425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212637425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212637425">(Oct 08 2020 at 00:55)</a>:</h4>
<p>You could use an opaque type that implements the mask trait as well but that doesn't seem as elegant</p>



<a name="212637427"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212637427" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212637427">(Oct 08 2020 at 00:55)</a>:</h4>
<p>i feel like the design of masking is threatening to become one of the largest and most complex apis in the whole stdlib, which feels like a failure to me, and bodes poorly for the project. <em>sigh</em></p>



<a name="212637437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212637437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212637437">(Oct 08 2020 at 00:55)</a>:</h4>
<p>I don't actually think masks have too many functions, fortunately.</p>



<a name="212637485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212637485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212637485">(Oct 08 2020 at 00:56)</a>:</h4>
<p>Comparisons, blends</p>



<a name="212637490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212637490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212637490">(Oct 08 2020 at 00:56)</a>:</h4>
<p>Masked loads and stores</p>



<a name="212637630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212637630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212637630">(Oct 08 2020 at 00:59)</a>:</h4>
<p>yeah i mean, i feel like we're still not even close to on the same page about whether this should be something like "safe_arch but portable" or something higher level. i definitely feel like the design now is leaning towards</p>
<ul>
<li>be safe_arch but portable</li>
<li>try to distract from this fact by adding more complexity on top</li>
</ul>
<p>which just feels like the worst possible option. anyway, i'm out for a bit.</p>



<a name="212637962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212637962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212637962">(Oct 08 2020 at 01:05)</a>:</h4>
<p>I think that problem is unique to masks since they're handled so fundamentally differently by different instruction sets</p>



<a name="212638018"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212638018" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212638018">(Oct 08 2020 at 01:06)</a>:</h4>
<p>But I agree that we haven't really settled that completely</p>



<a name="212638091"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212638091" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212638091">(Oct 08 2020 at 01:07)</a>:</h4>
<p>Though I'm not sure "safe_arch but portable" is the right way to look at it, target-feature 1.1 handles the safe portion of that (or should, at least)</p>



<a name="212638180"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212638180" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212638180">(Oct 08 2020 at 01:09)</a>:</h4>
<p>sorta. safe_arch provides reference based apis in some sports so the pointer using functions are kept valid</p>



<a name="212638185"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212638185" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212638185">(Oct 08 2020 at 01:09)</a>:</h4>
<p>Yeah, that's definitely something to handle here</p>



<a name="212638280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212638280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212638280">(Oct 08 2020 at 01:11)</a>:</h4>
<p>I think I'm going to re-state my position even though it has essentially not changed since last time: We proceed with wide masks as default, and narrow masks are available as a set of extensions that you can access if you know it will help you on a specific platform.</p>



<a name="212638356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212638356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212638356">(Oct 08 2020 at 01:12)</a>:</h4>
<p>That is the simplest, most future-compatible plan, which also serves the most users as best as possible.</p>



<a name="212638792"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212638792" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212638792">(Oct 08 2020 at 01:21)</a>:</h4>
<p>Yeah I guess I should clarify what I meant:</p>
<p>safe_arch exposes a safe version of the entire API of every intel ISA. That is to say, if an operation exists and can possibly be exposed safely, it is, even if it's weird, redundant, and etc.</p>
<p>The reason I make this comparison is: Exposing multiple families of mask types because some ISAs handle one more efficiently than the other very much feels like this. </p>
<p>Now, we do have the option of saying: "okay, anything any simd ISA can do, we should have a portable version we expose." This is basiclaly what <span class="user-mention" data-user-id="239881">@Josh Triplett</span>  was suggesting earlier. I'm actually not even opposed to that if it's the explicit design decision, and i don't think safe_arch is a bad library. I think the result will be a large and complex API, but it also would be undeniably useful for a lot of stuff.</p>
<p>Now, I won't lie and say it would be my choice for what the best thing to do here is — it's also very different from the charter that I saw earlier. IMO a <em>good</em> API needs to be willing to cut functionality in order to keep things simple even if it means not every case can be optimally handled.</p>
<p>That said, perhaps this group just can't come to agreements here, and other design are worth considering.</p>



<a name="212639187"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212639187" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212639187">(Oct 08 2020 at 01:30)</a>:</h4>
<p>Just as a quick footnote before I do go:</p>
<blockquote>
<p>I think that problem is unique to masks since they're handled so fundamentally differently by different instruction sets</p>
</blockquote>
<p>It's just an example of a case where we can't provide a single operation that's optimal everywhere. Whenever this happens we will have the choice to weigh the various tradeoffs and make a choice for one over the others, or expose multiple similar operations (increasing API complexity).</p>
<p>I think this kind of thing is basically <em>everywhere</em> in this problem domain, and is not at all unique to masks (even if masks are worse because the duplication requires a large family of types instead of just like, two functions).</p>
<p>Our discussion here kinda makes me feel like a decision to cut will be frequently a big uphill fight, which is just exhausting (although perhaps it will depend on which ISAs are pessimized)...</p>
<p>(Anyway, I'm genuinely not opposed to just deciding up front to expose it all — that's honestly simpler in a lot of ways...)</p>



<a name="212639400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212639400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212639400">(Oct 08 2020 at 01:35)</a>:</h4>
<p><span class="user-mention silent" data-user-id="224471">Lokathor</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20movemasquerade/near/212638356">said</a>:</p>
<blockquote>
<p>That is the simplest, most future-compatible plan, which also serves the most users as best as possible.</p>
</blockquote>
<p>simple it may be, but I'd argue it's not the best one for the future: recently I've seen various SIMD instruction sets moving to narrower masks, as part of enabling predicated execution and reducing power usage: AVX512 (1 bit per lane), ARM SVE (1 bit per byte), RISC-V V (1 bit per lane), SimpleV (1 bit per lane). the only recently designed SIMD instruction set that i've seen that doesn't use narrower masks is RISC-V P which is designed for embedded processors and probably integer only. All the other SIMD instruction sets I'm aware of were designed more than 10 years ago or are small extensions of existing SIMD instruction sets.</p>



<a name="212640016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212640016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212640016">(Oct 08 2020 at 01:47)</a>:</h4>
<p>there's also the NEC SX-Aurora which is also 1 bit per lane</p>



<a name="212725721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212725721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212725721">(Oct 08 2020 at 17:46)</a>:</h4>
<p>I wouldn't overcalibrate on this dispute, I think it's just a consequence of everyone kind of bumbling in with the assumption that everyone else was on exactly the same page and then realizing "oh wait, we are actually on pretty different footing in many places", it just took an issue with this amount of nuance for these differences to be fully exposed. I also think there's differences in perceived difficulties for various approaches, and a need to discuss things with other teams, and we will eventually sort things out.</p>
<p>We just have to keep talking and eventually Aumann's agreement theorem will kick in.</p>



<a name="212725820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212725820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212725820">(Oct 08 2020 at 17:47)</a>:</h4>
<p>I choose to act irrationally. All masks must be 3 bits</p>



<a name="212725842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212725842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212725842">(Oct 08 2020 at 17:47)</a>:</h4>
<p>lol</p>



<a name="212725932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212725932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212725932">(Oct 08 2020 at 17:48)</a>:</h4>
<p>as long as you <a href="https://www.youtube.com/watch?v=wbOTkDn49qI">https://www.youtube.com/watch?v=wbOTkDn49qI</a></p>
<div class="youtube-video message_inline_image"><a data-id="wbOTkDn49qI" href="https://www.youtube.com/watch?v=wbOTkDn49qI"><img src="https://i.ytimg.com/vi/wbOTkDn49qI/default.jpg"></a></div>



<a name="212731921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212731921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212731921">(Oct 08 2020 at 18:35)</a>:</h4>
<p>&lt;ignore this sent to wrong topic&gt;</p>



<a name="212736151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212736151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212736151">(Oct 08 2020 at 19:11)</a>:</h4>
<p>FWIW I said before about the charter</p>
<blockquote>
<p>i kind of feel like it's unrealistic to push everything here into the compiler</p>
</blockquote>
<p>I take this back. I hadn't realized that ultimately the implementation strategy it describes is very close to what <code>packed_simd</code> currently does, so yeah.</p>
<p>I still think it's kinda vague (and it comes very close to invoking a sufficiently smart compiler")... but I can firm details up by reviewing packed_simd's implementation strategy.</p>
<p>This doesn't answer any questions around masking, but I'm less terrified of the thought of having 1000 more of these threads as we go through every piece of SIMD functionality.</p>



<a name="212794818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212794818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212794818">(Oct 09 2020 at 08:12)</a>:</h4>
<p>I believe we will have gradually less of these as more information diffuses, but we're going to have, mm, probably three more before we have enough information diffusion to get all the hidden assumptions into the open and then start taking them down. One of them might be more acrimonious than this one! That one will be fun (not).</p>
<p><del>And it's true that a lot of stuff requires a "sufficiently smart compiler" but really it's 2020, if your compiler isn't serving you breakfast in bed you need to be upping your expectations.</del></p>



<a name="212878889"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212878889" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212878889">(Oct 09 2020 at 21:43)</a>:</h4>
<p>...huh, simd_select truncates to i1xN? <a href="https://github.com/rust-lang/rust/commit/9a44448a252a94bf6b99388cab82aa9cd4595207#diff-811abed36cfd18fc1f7a6af984e0fd39R1170">https://github.com/rust-lang/rust/commit/9a44448a252a94bf6b99388cab82aa9cd4595207#diff-811abed36cfd18fc1f7a6af984e0fd39R1170</a></p>



<a name="212879005"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212879005" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212879005">(Oct 09 2020 at 21:44)</a>:</h4>
<p>the issue with i1xN was only when llvm could not see where it was coming from. e.g. if it came from something that failed to get inlined it would cause terrible code, otherwise it was fine.</p>



<a name="212879023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212879023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212879023">(Oct 09 2020 at 21:45)</a>:</h4>
<p>nod.</p>



<a name="212879128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212879128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212879128">(Oct 09 2020 at 21:46)</a>:</h4>
<p>That this is already the implicit mask vector does suggest that either the LLVM repr is less of a problem than expected or we have Deeper Problems.</p>



<a name="212879337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212879337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212879337">(Oct 09 2020 at 21:48)</a>:</h4>
<p>it seemed like when reading/wriing to memory or returning across function boundaries it turnd &lt;i1 x N&gt; into a concrete representation (possibly [bool; N]) and then had to undo that on the other side. e.g. the &lt;i1 x N&gt; is only good if its actually allowed to be represented that way</p>



<a name="212879824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212879824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212879824">(Oct 09 2020 at 21:54)</a>:</h4>
<p>that is: <a href="https://gcc.godbolt.org/z/3YjbW3">https://gcc.godbolt.org/z/3YjbW3</a></p>
<ul>
<li>on line 3 the function returns the &lt;i1 x N&gt;</li>
<li>on line 8 the the returned value is given to a call</li>
</ul>
<p>this is an optimization bounary because llvm doesnt know on line 3 what the caller will need, and so on line 8 it ends up having to do a crapload of work.</p>
<p>conversely, if llvm does know what the caller needs, it can keep things in the optimal format, which is why f_sse_inlined does great.</p>



<a name="212879940"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212879940" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212879940">(Oct 09 2020 at 21:56)</a>:</h4>
<p>as i see it, the problem is we can't ensure that &lt;i1 x N&gt; values have ambiguous representations forever and then just use the optimal thing everywhere — llvm would need to do whole program optimization for that sort of thing. </p>
<p>in practice, functions that dont get inlined, and values that are loaded from memory are probably going to have that problem.</p>



<a name="212880000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212880000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212880000">(Oct 09 2020 at 21:57)</a>:</h4>
<p>yeah, in general we need to make our worst case as good as possible, not the other way around.</p>



<a name="212880016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212880016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212880016">(Oct 09 2020 at 21:57)</a>:</h4>
<p>we could try and file an llvm bug about this but it seems very unsurprising that this is the way this works.</p>



<a name="212880246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212880246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212880246">(Oct 09 2020 at 22:00)</a>:</h4>
<p>FWIW in the past couple days i pretty much decided i'd be fine with the 3 mask types design. or at least, we can try it for a while and go from there, and take a look later after more of the api is there to bounce against</p>



<a name="212880666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212880666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212880666">(Oct 09 2020 at 22:06)</a>:</h4>
<p>i think 2 types (bitmasks and wide masks) would probably be better though since they do enable different sets of algorithms, even if there is overlap.</p>
<p>the 3rd type (the more limited/representation-unspecified type which uses the fast thing for your target) seems more problematic to me still</p>



<a name="212881049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212881049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212881049">(Oct 09 2020 at 22:13)</a>:</h4>
<p>Other than the number of types, the API is actually uncomplex</p>



<a name="212881174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212881174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212881174">(Oct 09 2020 at 22:15)</a>:</h4>
<p>I wonder--what are the chances some other form of mask becomes common in the future, if we already have 2?</p>



<a name="212881175"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212881175" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212881175">(Oct 09 2020 at 22:15)</a>:</h4>
<p>Not that I can think of any other way to possibly do it but who knows</p>



<a name="212881223"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212881223" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212881223">(Oct 09 2020 at 22:15)</a>:</h4>
<p>and after looking through packed_simd and thinking both: "wow this is a lot" and "yep seems like we'll certainly want a lot of this", the number of mask types doesn't bother me as much. i also think it's plausible that moving forward will either reduce or increase our concerns around what llvm does when it can't inline mask code, and a good way to know is to go forward</p>



<a name="212881439"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212881439" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212881439">(Oct 09 2020 at 22:19)</a>:</h4>
<p>oh i wanted to ask <span class="user-mention" data-user-id="312331">@Caleb Zulawski</span>, the avx512 mask instructions, do those trigger the frequency transition you get from some avx512 ops?</p>



<a name="212881571"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212881571" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212881571">(Oct 09 2020 at 22:20)</a>:</h4>
<p>On full 512 bit vectors yes</p>



<a name="212881603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212881603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212881603">(Oct 09 2020 at 22:21)</a>:</h4>
<p>On smaller vectors I don't believe so (though of course AVX has its own frequency drop)</p>



<a name="212888796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212888796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212888796">(Oct 10 2020 at 00:00)</a>:</h4>
<p>I should note that the exact details of the transition and the overhead vary based on CPU</p>



<a name="212889265"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212889265" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212889265">(Oct 10 2020 at 00:03)</a>:</h4>
<p>yeah i'm not more worried about it now than i was before. in practice it does make "use wider vectors" sometimes dodgy but with an api like we have here going back and forth to experiment should be roughly trivial. it has always worried me a little about 512 tho, but that's not to say that worry impacts the api design at all</p>



<a name="212889547"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212889547" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212889547">(Oct 10 2020 at 00:08)</a>:</h4>
<p>With avx512 going wider can be worth it despite the frequency change if you're doing a lot of masking since it's essentially free. Straight math doesn't see as much of a benefit</p>



<a name="212889605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212889605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212889605">(Oct 10 2020 at 00:09)</a>:</h4>
<p>(I assume the compiler will be smart enough to merge mask and math ops from std::simd)</p>



<a name="212894397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212894397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212894397">(Oct 10 2020 at 02:17)</a>:</h4>
<p>as long as we don't promise specific instructions we can continue tweaking performance concerns based on AVX512 and such well into 2030.</p>



<a name="212897928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212897928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212897928">(Oct 10 2020 at 04:06)</a>:</h4>
<p>but in 2031 avx512 will be cancalled and everyone will have to move on with life.</p>



<a name="212946366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/212946366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#212946366">(Oct 11 2020 at 03:24)</a>:</h4>
<p><span class="user-mention silent" data-user-id="209168">Thom Chiovoloni</span> <a href="#narrow/stream/257879-project-portable-simd/topic/The.20movemasquerade/near/212880246">said</a>:</p>
<blockquote>
<p>FWIW in the past couple days i pretty much decided i'd be fine with the 3 mask types design. or at least, we can try it for a while and go from there, and take a look later after more of the api is there to bounce against</p>
</blockquote>
<p>:)</p>
<p>One additional benefit of the 3 mask type design is it allows platforms that default to even weirder mask types to use that for the representation-unspecified mask type, instead of having to use one or the other of the already defined mask types.</p>



<a name="214894644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/214894644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#214894644">(Oct 28 2020 at 20:40)</a>:</h4>
<p>To bring back this discussion, I've opened a review on an initial design that supports multiple mask types: <a href="https://github.com/rust-lang/stdsimd/pull/44">https://github.com/rust-lang/stdsimd/pull/44</a></p>



<a name="215190209"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20movemasquerade/near/215190209" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Mannix <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20movemasquerade.html#215190209">(Oct 31 2020 at 12:48)</a>:</h4>
<p>Nominated for our next sync up <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>